Skip to content

fix: exclude non-let definitions from docs Functions index#6024

Open
prql-bot wants to merge 1 commit into
mainfrom
fix/docs-generator-dangling-anchors
Open

fix: exclude non-let definitions from docs Functions index#6024
prql-bot wants to merge 1 commit into
mainfrom
fix/docs-generator-dangling-anchors

Conversation

@prql-bot

Copy link
Copy Markdown
Collaborator

Problem

prqlc experimental doc builds a "Functions" index that links to per-function detail sections. The index listed every VarDef, but the detail sections were only emitted for VarDefKind::Let. A top-level pipeline becomes a main var-def (and into produces another non-let kind), so those appeared in the index linking to an anchor that no detail section ever generated — a dangling link.

Reproduction (before this change):

$ printf 'let f = a -> a\nfrom employees | select {name}\n' | prqlc experimental doc
## Functions
* [f](#f)
* [main](#main)   ← links to #main, but no `### main` section exists

### f
...

The HTML output had the same issue with #fn-main.

Fix

The index loop and the detail loop each decided independently what counts as a documented function, and they had drifted. This consolidates that decision into a single is_documented_function helper used by both loops in both the HTML and Markdown generators, so the index can never list an entry the detail loop skips. The redundant stmts.clone().into_iter() passes for these loops are replaced with stmts.iter().

Test

Added generate_docs_excludes_main_pipeline, which runs experimental doc on input containing a top-level pipeline and asserts the main entry no longer appears in the Functions index. Without the fix the index regains the dangling * [main](#main) line and the test fails.

Found during the nightly code-quality survey.

The `prqlc experimental doc` Functions index listed every `VarDef`, but the
detail sections were only emitted for `VarDefKind::Let`. A `main` pipeline (or
any `into` def) therefore produced an index entry linking to an anchor
(`#fn-main` / `#main`) that no detail section ever generated — a dangling link.

Consolidate the "is a documented function" predicate into a single helper used
by both the index and detail loops so they can no longer drift, and add a
regression test exercising a top-level pipeline.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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