Add option to add external links to source code #1770
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.
This feature is meant as a compromise between copying all source code to the documentation directory (
outputSourceFiles = true
), and having no links to the source code at all (outputSourceFiles = false
). Instead, this option allows you to link to an external source code repository (e.g. GitHub or GitLab).templates.default.externalSourceLinks.urlPrefix
option points to the location where the source code is hosted; the path of the file is appended to it.templates.default.externalSourceLinks.linenoPrefix
option defaults to'L'
and refers to theL
in#L5
which points to line 5 on both GitHub and GitLab.This was manually tested against v3, not v4, because I couldn't get
npm install
ing v4 from GitHub or a sibling directory to work. I also didn't see any tests for theoutputSourceFiles
feature, so I wasn't sure how to test this. All existing tests pass in v4 too, though, and the patch applied cleanly, so I imagine it should work.Here is another example for how I intend to use this, automatically taking the repository url and version tag from package.json: https://github.com/twiss/openpgpjs/blob/v5-test/.jsdocrc.js. This should be convenient when updating the documentation whenever you release a new version, for example. That should also minimize the risk that the linked source code doesn't match the processed source code.