-
-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: include root index.html
in --html
output
#104
ENH: include root index.html
in --html
output
#104
Conversation
pdoc/cli.py
Outdated
@@ -487,6 +487,25 @@ def docfilter(obj, _filters=args.filter.strip().split(',')): | |||
# Two blank lines between two modules' texts | |||
sys.stdout.write(os.linesep * (1 + 2 * int(module != modules[-1]))) | |||
|
|||
# Add the root index.html at the top level | |||
if args.html: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is adapted from WebDoc.do_GET
on "/"
. That one doesn't use the pydoc.Module
class for the root index. It uses args.modules
and imports the modules to get the name and docstring.
When I tried doing it in the same way here, there were some inconsistencies with the rest of the --html
behavior that was causing some weird breakages and test errors. Otherwise, I would have pulled the logic out into a helper function.
modules=module_tuples, | ||
**template_config) | ||
index_file = path.join(args.output_dir, 'index.html') | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this logic is adapted from write_files
. I couldn't use it directly, since it expects a pdoc.Module
as input, so I just copy-pasted. I can go back and refactor that to be more DRY if you prefer.
@@ -487,6 +492,25 @@ def docfilter(obj, _filters=args.filter.strip().split(',')): | |||
# Two blank lines between two modules' texts | |||
sys.stdout.write(os.linesep * (1 + 2 * int(module != modules[-1]))) | |||
|
|||
if args.html and args.html_index: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll name the arg whatever you want, but this is the general idea.
To my point about breaking automation: The CI build was failing for "Deploy" with my initial PR, but it's passing now that I've put the feature behind a flag. |
Let's discuss this back in #101. |
Implements #101 .
It adds the root
index.html
from the--http
mode to the static--html
output.To avoid breaking people's automations, I've put this feature behind a flag (
--html-index
) and left the default behavior alone.I also added the breadcrumbs to the module pages when
--html-index
is active.You can use as much or as little of this as you want. I did this in several small commits so you can see all the options side-by-side.
What's left