Skip to content

Render package __init__.py at the directory's index.html#46

Closed
danceratopz wants to merge 1 commit intoSamWilsn:masterfrom
danceratopz:mv-init-to-index
Closed

Render package __init__.py at the directory's index.html#46
danceratopz wants to merge 1 commit intoSamWilsn:masterfrom
danceratopz:mv-init-to-index

Conversation

@danceratopz
Copy link
Copy Markdown

@danceratopz danceratopz commented Apr 27, 2026

Summary

  • Route __init__.py sources to <dir>/index so each package's landing page (index.html) is the rendered module documentation instead of an empty directory listing
  • Keep the synthetic ListingSource in the navigation tree, but skip writing its file in cli.py when a non-listing source already covers the same output path — this preserves the docc/, plugins/, etc. entries in parent listings while letting the module page win at index.html
  • The module template already renders a leaf siblings listing under "Browse", so the directory listing remains visible on the package's index page

Example

image

Test plan

  • tox -e py3 passes (lint + tests + docc self-build)
  • tox -e type passes (pyre)
  • Generated docs no longer contain any __init__.py.html files; index.html exists for every package and contains the rendered __init__.py
  • Cross-references and breadcrumbs resolve to <pkg>/index.html
  • Parent listings still link to subpackages (e.g. src/index.html lists docc/)

Previously each package's index.html showed only an empty directory
listing while __init__.py.html held the module documentation. Route
__init__.py sources to <dir>/index so the package's documentation is
the landing page; the cli skips writing the synthetic ListingSource
when a non-listing source already covers that path, preserving
parent-listing navigation entries.
Copy link
Copy Markdown
Owner

@SamWilsn SamWilsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is giving special privilege to the listing plugin, and feels a bit hacky.

I'm not sure what a better solution in this vein would be. Maybe every source could have a priority and the highest priority claims the output path? That way there's no special case for listings.

That said, I think the better solution is still to not generate the listing in the first place, but I've been having some difficulty coming up with an elegant implementation of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants