Skip to content

docs(docs-infra): fix missing code examples in the API reference#59004

Closed
hawkgs wants to merge 12 commits intoangular:mainfrom
hawkgs:docs/fix-code-examples
Closed

docs(docs-infra): fix missing code examples in the API reference#59004
hawkgs wants to merge 12 commits intoangular:mainfrom
hawkgs:docs/fix-code-examples

Conversation

@hawkgs
Copy link
Copy Markdown
Member

@hawkgs hawkgs commented Dec 2, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #56321

What is the new behavior?

The new examples extraction and interpolation mechanism is integrated into the API gen JSON extraction phase since I thought that it makes most sense given the JSON files could be potentially consumed by other services and having the examples already inlined is desired. Let me know, if that's good. Currently, all {@example}-s are being targeted by the script and then replaced with the respective code example wrapped in a Markdown code block.

The extractor/parser supports various #docregion use variations that can be checked in the unit tests. It is still possible that I missed a use case but these are based on the different examples that I explored during the implementation.

It is important to note that there are about half a dozen examples that are still missing because of the <code-example> usage. Some of the instances have already been replaced with {@example} – those that have only a region parameter (a63b524). The remaining instances are left because they contain a header param. All that being said, I want to start a discussion in that regard – should we get rid of <code-example> completely in favor of {@example} or vice versa? Obviously, there are other details that have to be taken into account like whether the output of this interpolation mechanism should produce Markdown or HTML but this is something that can be decided as a secondary thing.

Does this PR introduce a breaking change?

  • Yes
  • No

The code examples in `package/examples` are now passed to the API JSON generator.
The script substitutes the JSDoc example tags with the respective code sample.
Add support for nested #docregion-s and modify the examples caching.
It seems that there are overlapping region markers and an example can be composed by multiple regions.
…amples

The transform is no longer relevant nor it served any functional purpose.
…ile types

Set the code block language highlighting based on the file type.
Setup the test suite and add the initial test.
Minor bug fixes found and implemented during testing.
Test all use cases that are supported by the interpolation mechanism.
…ram to @example-s

Replace all <code-example>-s within TS files that contain only a path and a region with JSDoc @example-s.
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: docs-infra Angular.dev application and infrastructure labels Dec 2, 2024
@ngbot ngbot bot added this to the Backlog milestone Dec 2, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 2, 2024

Deployed adev-preview for 88b4fc6 to: https://ng-dev-previews-fw--pr-angular-angular-59004-adev-prev-7icqucjj.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Add missing file header comments and update others.
@hawkgs hawkgs force-pushed the docs/fix-code-examples branch from 51029a8 to f9a42bf Compare December 3, 2024 08:41
@pullapprove pullapprove bot requested review from josephperrott and removed request for devversion December 3, 2024 08:41
Use `angular-ts` instead of `typescript` and `angular-html` instead of `html`.
Copy link
Copy Markdown
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: global-approvers

@josephperrott josephperrott added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Dec 4, 2024
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
Add missing file header comments and update others.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
…59004)

Use `angular-ts` instead of `typescript` and `angular-html` instead of `html`.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
The script substitutes the JSDoc example tags with the respective code sample.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
Add support for nested #docregion-s and modify the examples caching.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
…#59004)

It seems that there are overlapping region markers and an example can be composed by multiple regions.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
…amples (#59004)

The transform is no longer relevant nor it served any functional purpose.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
…ile types (#59004)

Set the code block language highlighting based on the file type.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
Setup the test suite and add the initial test.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
Minor bug fixes found and implemented during testing.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
Test all use cases that are supported by the interpolation mechanism.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
…ram to @example-s (#59004)

Replace all <code-example>-s within TS files that contain only a path and a region with JSDoc @example-s.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
Add missing file header comments and update others.

PR Close #59004
pkozlowski-opensource pushed a commit that referenced this pull request Dec 4, 2024
…59004)

Use `angular-ts` instead of `typescript` and `angular-html` instead of `html`.

PR Close #59004
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 4, 2025
@hawkgs hawkgs deleted the docs/fix-code-examples branch January 4, 2025 15:06
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…#59004)

The code examples in `package/examples` are now passed to the API JSON generator.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
The script substitutes the JSDoc example tags with the respective code sample.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
Add support for nested #docregion-s and modify the examples caching.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…angular#59004)

It seems that there are overlapping region markers and an example can be composed by multiple regions.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…amples (angular#59004)

The transform is no longer relevant nor it served any functional purpose.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…ile types (angular#59004)

Set the code block language highlighting based on the file type.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
Setup the test suite and add the initial test.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
Minor bug fixes found and implemented during testing.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
Test all use cases that are supported by the interpolation mechanism.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…ram to @example-s (angular#59004)

Replace all <code-example>-s within TS files that contain only a path and a region with JSDoc @example-s.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
Add missing file header comments and update others.

PR Close angular#59004
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…ngular#59004)

Use `angular-ts` instead of `typescript` and `angular-html` instead of `html`.

PR Close angular#59004
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker adev: preview area: docs-infra Angular.dev application and infrastructure detected: feature PR contains a feature commit target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants