Skip to content
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

Add src-link generator #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add src-link generator #78

wants to merge 1 commit into from

Conversation

onmax
Copy link
Contributor

@onmax onmax commented Oct 9, 2024

This PR introduces a new generator called src-link for AutoMD. The generator allows users to create Markdown links to specific lines in source code files:

Examples:

GitHub URLs

<!-- automd:src-link url="gh:nuxt/nuxt/blob/main/packages/schema/src/types/hooks.ts" pattern="export interface NuxtHooks {" label="schema source code" -->
<!-- /automd -->

Will produce:

[schema source code](https://github.com/nuxt/nuxt/blob/main/packages/schema/src/types/hooks.ts#L83)

GitHub URLs with Regex

<!-- automd:src-link url="gh:nuxt/nuxt/blob/main/packages/schema/src/types/hooks.ts" pattern="Kit[^}]*'kit:compatibility" label="Kit compatibility" -->
<!-- /automd -->

Will produce:

[Kit compatibility](https://github.com/nuxt/nuxt/blob/main/packages/schema/src/types/hooks.ts#L84-L91)

Relative URLs

<!-- automd:src-link url="./types/hooks.ts" pattern="export interface NuxtHooks {" label="schema source code" -->
<!-- /automd -->

Will produce:

[schema source code](./types/hooks.ts:83)

Check the test cases to see more options.

Related #77

@onmax onmax changed the title feat: added src-link generator [WIP] Add src-link generator Oct 9, 2024
package.json Outdated
@@ -30,7 +30,8 @@
"prepack": "pnpm build",
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags && pnpm build --stub",
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
"test:types": "tsc --noEmit --skipLibCheck"
"test:types": "tsc --noEmit --skipLibCheck",
"test:generators": "vitest run test/generators"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please extend existing tests? 🙏🏼

https://github.com/unjs/automd/tree/main/test/fixture

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 95.14563% with 5 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@ae3ca7a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/generators/src-link.ts 95.04% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #78   +/-   ##
=======================================
  Coverage        ?   77.55%           
=======================================
  Files           ?       18           
  Lines           ?     1114           
  Branches        ?      158           
=======================================
  Hits            ?      864           
  Misses          ?      249           
  Partials        ?        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@onmax onmax changed the title [WIP] Add src-link generator Add src-link generator Oct 10, 2024
@onmax onmax requested a review from pi0 October 10, 2024 09:40

<!-- automd:src-link url="gh:nuxt/nuxt/blob/main/packages/schema/src/types/hooks.ts" pattern="\"export" interface NuxtHooks" label="\"schema" source code" -->

<!-- ⚠️ Unknown generator:`src-link`. -->
Copy link
Contributor Author

@onmax onmax Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to register the generator in the config/automd

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.

2 participants