Skip to content

Commit 47f867f

Browse files
authored
Fix doc generator to avoid incorrect check (#720)
The `reference/_generate.py` script was incorrectly filtering out commands which did not have the `adoc_skip` attribute. This attribute was actually removed in #713 , and the check therefore filters out *all* commands. To remedy: - fix the check - add logging to the doc generator to help identify issues in the future - add a quick `--debug` flag which is used in CI to ensure that we get detailed output from the doc build
1 parent 5356635 commit 47f867f

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
python -m pip install -e .
1919
- name: Generate Autodoc
2020
run: |
21-
./reference/_generate.py
21+
./reference/_generate.py --debug
2222
# bundle as tarball without the _generate.py script or .gitignore
2323
# use `-h` to dereference the changelog link
2424
tar --exclude "*.py" --exclude '.gitignore' -czf cli-reference.tar.gz -h reference/

reference/_generate.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
44
based originally on click-man, but significantly specialized for the globus-cli
55
"""
6+
import argparse
7+
import logging
68
import os
79
import textwrap
810
import time
@@ -16,6 +18,8 @@
1618
CLI = load_entry_point("globus-cli", "console_scripts", "globus")
1719
TARGET_DIR = os.path.dirname(__file__)
1820

21+
log = logging.getLogger(__name__)
22+
1923
try:
2024
# try to fetch last release date
2125
last_release = requests.get(
@@ -126,9 +130,11 @@ def __str__(self):
126130

127131
def write_pages():
128132
for ctx in iter_all_commands():
129-
if not isinstance(ctx.command, click.Group) and not getattr(
130-
ctx.command, "adoc_skip", True
131-
):
133+
log.debug("write_pages() handling: '%s'", ctx.command_path)
134+
if not isinstance(ctx.command, click.Group):
135+
log.info(
136+
"write_pages() identified non-group command: '%s'", ctx.command_path
137+
)
132138
cmd_name = ctx.command_path.replace(" ", "_")[len("globus_") :]
133139
path = os.path.join(TARGET_DIR, cmd_name + ".adoc")
134140
with open(path, "w") as f:
@@ -160,6 +166,21 @@ def generate_index():
160166
f.write(ctx.command.get_short_help_str() + "\n\n")
161167

162168

163-
if __name__ == "__main__":
169+
def main():
170+
parser = argparse.ArgumentParser(
171+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
172+
)
173+
parser.add_argument("--debug", help="enable debug logging", action="store_true")
174+
args = parser.parse_args()
175+
176+
if args.debug:
177+
logging.basicConfig(level=logging.DEBUG)
178+
else:
179+
logging.basicConfig(level=logging.INFO)
180+
164181
write_pages()
165182
generate_index()
183+
184+
185+
if __name__ == "__main__":
186+
main()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ commands = mypy src/
6868
[testenv:reference]
6969
whitelist_externals = find
7070
commands_pre = find reference/ -name "*.adoc" -type f -delete
71-
commands = python ./reference/_generate.py
71+
commands = python ./reference/_generate.py {posargs}
7272

7373
[testenv:twine-check]
7474
skip_install = true

0 commit comments

Comments
 (0)