Skip to content

Fix title fallback when the CLI passes title=None - #64

Open
jiacheng-fu wants to merge 1 commit into
SystemRDL:mainfrom
jiacheng-fu:fix-title-none-fallback
Open

Fix title fallback when the CLI passes title=None#64
jiacheng-fu wants to merge 1 commit into
SystemRDL:mainfrom
jiacheng-fu:fix-title-none-fallback

Conversation

@jiacheng-fu

Copy link
Copy Markdown

Fixes #63

Problem

The peakrdl html CLI defines --title with default=None and always forwards title=options.title into HTMLExporter.export(). The exporter's fallback uses kwargs.pop("title", <default>), which only fires when the kwarg is absent — so the explicit None wins and generated pages render a literal None:

<title>None</title>
...
<div id="_SBTitlebox">None</div>

Fix

Treat an explicit title=None the same as an omitted title and fall back to "<top node name> Reference". Fixing it in the exporter rather than the CLI plugin covers every API caller that passes None, and matches the docstring, which describes title as an optional override. An explicit --title/title= still wins, and an empty string is still respected as-is.

The docstring now states the fallback value.

Verification

On example/turboencabulator.rdl:

Invocation Before After
peakrdl html turboencabulator.rdl -o out <title>None</title> <title>Turbo-Encabulator Reference</title>
peakrdl html turboencabulator.rdl -o out --title Custom <title>Custom</title> <title>Custom</title>

pylint --rcfile test/pylint.rc is clean and mypy reports no new issues relative to main.

Note: footer on the line above has the same latent pattern (kwargs.pop with a computed default), though the CLI never forwards it, so it isn't user-visible today. Happy to apply the same treatment in this PR if you'd like.

The peakrdl html CLI defines --title with a default of None and always
forwards it to HTMLExporter.export(), so the exporter's kwargs.pop
fallback never fired and generated pages rendered a literal "None" as
the page and sidebar title.

Treat an explicit title=None the same as an omitted title: fall back to
"<top node name> Reference". An explicit --title still overrides.

Fixes SystemRDL#63
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.

peakrdl html passes title=None, preventing fallback to top node name

1 participant