-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src-link
generator
#77
Comments
link
generator for AutoMD with pattern search and line highlightingcode-link
generator
I like this idea. I think it can also support local files like A completely alternative way btw is to use a browser (chromium only: chrome, edge, opera, brave) feature using Docs: https://developer.mozilla.org/en-US/docs/Web/URI/Fragment/Text_fragments Try this: https://github.com/nuxt/nuxt/blob/main/packages/schema/src/types/hooks.ts#:~:text=export%20interface%20NuxtHooks (open in external tab) |
Using |
It works if you open above link as an external link on chrome.
PR is welcome thanks 👍🏼 |
Describe the feature
I'd like to propose a new generator for AutoMD that helps automate the process of linking to specific lines in GitHub files by looking for patterns. The goal is to reduce the manual effort of maintaining line numbers in the documentation when linking to GitHub files.
We currently use links like this:
This works, but requires us to manually enter and maintain line numbers, which can change over time as the source code evolves.
Proposed solution
Introduce a new
automd:link
generator that automatically fetches a file from a GitHub repository, searches for a specified pattern, and generates a link with the correct line highlighting based on the location of the pattern.Proposed syntax:
Parameters:
url
: The GitHub URL where the file is located.pattern
: The pattern (e.g. function name, method, etc.) to search for in the file. This can be also a JS Regex.label
: The text for the link to appear in the markdown output.Instead of writing:
We could simplify it like this:
Check the <!-- automd:link url="gh:nuxt/nuxt/blob/main/packages/schema/src/types/hooks.ts" pattern="export interface NuxtHooks" label="schema source code" --> for all available hooks.
AutoMD would fetch the file, search for the pattern
export interface NuxtHooks
, and generate the appropriate link with the correct line number.Advantages
Reduced manual updates: No need to manually update line numbers in the documentation as the code evolves.
Implementation notes
automd:fetch
, but instead of fetching the full file contents, it would search for the specified pattern and return a markdown link with the GitHub file and the correct line number.highlightLines
, to specify whether only one line or a range of lines should be highlighted.PS: This is a problem I was facing few weeks ago
Additional information
The text was updated successfully, but these errors were encountered: