Skip to content

fix: only generate links to modules whose source files still exist - #421

Open
david-christiansen wants to merge 5 commits into
leanprover:mainfrom
david-christiansen:live-module-filter-pr
Open

david-christiansen wants to merge 5 commits into
leanprover:mainfrom
david-christiansen:live-module-filter-pr

Conversation

@david-christiansen

Copy link
Copy Markdown
Contributor

When a module is deleted, rebuilding documentation can leave stale module rows in the database. This PR adds a source path column to the modules table so the HTML generator can check whether the source file still exists and disregard the module if it doesn't.

This change removes obsolete content from the tactic list as well as obsolete links.

Source paths are stored relative to the module's package, which is now also stored. Lake now passes package directories to HTML generation. This keeps DB files cacheable and makes them robust to varying Lake settings that change where package sources are placed.

When a module is deleted, rebuilding documentation can leave stale
module rows in the database. This PR adds a source path column to the
modules table so the HTML generator can check whether the source file
still exists and disregard the module if it doesn't.

This change removes obsolete content from the tactic list as well as
obsolete links.

Source paths are stored relative to the module's package, which is now
also stored. Lake now passes package directories to HTML
generation. This keeps DB files cacheable and makes them robust to
varying Lake settings that change where package sources are placed.
@david-christiansen

Copy link
Copy Markdown
Contributor Author

I believe this supersedes #416, and it can serve as a basis for #419 (which can provide a gc command for the DB that deletes rows whose source files are gone).

#416 resolves whether to link to module differently: it checks if it's either imported, or if there's already HTML for it. I think that approach has the following disadvantages relative to this one:

  • For a cold build, some links won't be generated that should be, because the HTML is not yet present. HTML generation would need to run twice for it to reach a fixed point, but the Lake trace won't register a change, so it's difficult to run a second time.
  • Stale HTML on disk after a module is deleted still results in extraneous links.
  • The deleted module's tactics are still in the tactic list (though this isn't fundamental and could be fixed).

The navigation bar and the search index are built from the pages and
the per-module search data on disk. They now cover only the modules
found in the linking context, so a module whose source file is deleted
is not included.
Updates the `headerData` command to also check whether files exist.
If a module's source path is bogus, `fromDb` now emits a warning on
stderr instead of just generating a page that can't be linked to.
Package names that weren't valid Lean identifiers, like `doc-gen4`,
were getting French-quoted.
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.

1 participant