fix(generator)+feat(code): page anchor once per file; Code infers lexer from filename - #78
Merged
Merged
Conversation
Thor's inject_into_file replaces every match of a Regexp `after:`, so the "page line not followed by a page line" anchor fired once per blank-line separated group and duplicated the registry entry. Anchor on the last `page` line as a String instead — one match, end of the last group. Refs #77 Claude-Session: https://claude.ai/code/session_01KsqvKPn1c1hWu6NSEQHy1W
DocsUI::Code(<<~YAML, filename: "config/deploy.yml") now highlights as YAML via Rouge's filename globs. Explicit lexer: still wins; no filename or an unguessable one keeps the ruby default so existing output is unchanged. Also the changelog entry for the generator fix. Refs #77 Claude-Session: https://claude.ai/code/session_01KsqvKPn1c1hWu6NSEQHy1W
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #77
Summary
docs_kit:pageinjected the registry line once per group.#registry_anchorreturned a Regexp (pageline not followed by apageline), and Thor'sinject_into_filereplaces every match of a Regexpafter:— so a grouped registry got one copy per group. The anchor is now the file's lastpageline as a String: one match, end of the last group.DocsUI::Codeinfers the lexer fromfilename:.lexer:now defaults tonil; resolution is explicitlexer:→ guess from the filename via Rouge's globs → ruby.config/deploy.yml→ yaml,Dockerfile→ docker,*.sh→ shell. Unguessable filename / no filename → ruby as before.AGENTS.mdtemplate, and CHANGELOG.Test plan
spec/generators/page_generator_spec.rb— grouped fixture (two groups, blank line + comment): exactly one line added after the lastpageline of the file; second run idempotent.spec/docs_ui/code_spec.rb—.yml→data-md-lang="yaml"with noerrspans;Dockerfile→ docker; explicitlexer:wins over the filename; unguessable filename → ruby; no args → ruby.bundle exec rspec— 953 examples, 0 failures (94.7% line coverage)bundle exec rubocop— no offensesdocs/with a path gem):bin/rails g docs_kit:page "Scratch" --group=Deployingtwice → one line at the end of the last groupDeviations & judgment calls
Rouge::Lexer.guessesinstead ofRouge::Lexer.guess. The issue namedguess(filename:)with anAmbiguousrescue, butguessanswersPlainTexton a no-match (e.g.filename: "notes"), which is indistinguishable from a real guess and would have turned unguessable filenames into plaintext instead of the required ruby fallback.guessesreturns an array — exactly one hit is a guess, zero or several is nil — and needs no rescue.code_filename_lexersconfig knob. The issue floated it as a possible follow-up for extension-less files (.dash/secrets); those still work with an explicitlexer:, so I didn't add config surface nobody has asked for yet.--syncmigration. TheAGENTS.mdtemplate change is a content edit an existing site picks up via the normal install/sync path; nothing new to install.https://claude.ai/code/session_01KsqvKPn1c1hWu6NSEQHy1W
Summary by cubic
Fixes the
docs_kit:pagegenerator adding a registry entry once per group instead of once per file, and makesDocsUI::Codeinfer the lexer fromfilename:when nolexer:is given.Bug Fixes
docs_kit:pagenow anchors on the file's lastpageline as a string, so grouped registries get exactly one new entry per run.New Features
DocsUI::Coderesolves the lexer as explicitlexer:→ filename guess via Rouge → ruby; unguessable filenames and no filename stay ruby.lexer:always overrides the filename guess.AGENTS.mdtemplate now describe the new behavior; no migration step is needed—existing sites pick up the template change via the normal install/sync path.Closes #77.
Written for commit 968d771. Summary will update on new commits.