[ feat ] Add source location metadata to generated HTML docs#3788
Open
cypheon wants to merge 2 commits into
Open
[ feat ] Add source location metadata to generated HTML docs#3788cypheon wants to merge 2 commits into
cypheon wants to merge 2 commits into
Conversation
The FC metadata is added as presentation-neutral attributes `data-src-mod` and `data-src-start` to track an identifier's originating module name and source file context, respectively. This additional information can be used by an external tool which has both the docs and the (annotated) source files available to attach links to the exact source position for each identifier.
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.
Description
Attach FC info to HTML docs via data-* attributes, to allow an external tool to jump from documentation to the exact line in the (annotated) source file.
Concept
My idea was to decouple as much as possible the documentation generation (core feature of Idris2) from any external (future) docs viewer applications and source-to-HTML converters (e.g. katla) that have broader scope.
Since the Idris2 compiler does not know where (and if) the source files will be placed relatively to the HTML files, it is not feasible to emit full links. The flag
--install-with-srccopies the source, but it's the plain source, not a format that allows jumping to a specific line.An external docs viewer knows if and where it can find the HTML-converted source files for a given package. It just needs the raw info: what the source filename is (represented by the module info) and where (most importantly which line) in that file a given identifier is declared.
Proposed solution
The FC metadata is added as presentation-neutral attributes
data-src-modanddata-src-startto track an identifier's originating module name and source file context, respectively.This additional information can be used by an external tool which has both the docs and the (annotated) source files available to attach links to the exact source position for each identifier. The linking can either be done with a post-processing step on the HTML files, or via injected JS, that's up to whatever tool is handling the linking.
Self-check
implementation, I have updated
CHANGELOG_NEXT.md