Skip to content

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
"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

@codecov
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