Skip to content

docs(docs-infra): Add cross-links to API pages#57346

Closed
JeanMeche wants to merge 2 commits intoangular:mainfrom
JeanMeche:adev/symbol-links
Closed

docs(docs-infra): Add cross-links to API pages#57346
JeanMeche wants to merge 2 commits intoangular:mainfrom
JeanMeche:adev/symbol-links

Conversation

@JeanMeche
Copy link
Member

@JeanMeche JeanMeche commented Aug 12, 2024

This commit adds links to our own symbols in the API pages, including the Code TOC, the description and the Usage notes.

This commit also add the implement/extends symbols for classes & interfaces.

The generation process now logs warnings for links that couldn't not be generated because the symbols can be resolved in the given context.

fixes #57128
fixes #57183
fixes #55571

Worthy examples:

@angular-robot angular-robot bot added area: docs Related to the documentation area: docs-infra Angular.dev application and infrastructure labels Aug 12, 2024
@ngbot ngbot bot added this to the Backlog milestone Aug 12, 2024
@github-actions
Copy link

github-actions bot commented Aug 12, 2024

Deployed adev-preview for 8bc381f to: https://ng-dev-previews-fw--pr-angular-angular-57346-adev-prev-ckp3dlh0.web.app

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

@JeanMeche JeanMeche force-pushed the adev/symbol-links branch 3 times, most recently from 1802547 to bc1710c Compare August 13, 2024 20:57
@JeanMeche JeanMeche marked this pull request as ready for review August 13, 2024 21:11
@JeanMeche JeanMeche requested a review from devversion August 13, 2024 21:11
@pullapprove pullapprove bot requested a review from crisbeto August 13, 2024 21:11
@JeanMeche JeanMeche changed the title docs(docs-infra): Add inner links in the API docs entries docs(docs-infra): Add inside links in the API docs entries Aug 13, 2024
@JeanMeche JeanMeche changed the title docs(docs-infra): Add inside links in the API docs entries docs(docs-infra): Add links to other symbols in the API docs Aug 13, 2024
Copy link
Member

Choose a reason for hiding this comment

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

I think this shows (for the other PR with the core/globals) that we need to maybe have module_name, and a "title" field? I'm worried we are using module_name for more, but then Dev-mode globals breaks

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we'll be able to reuse the logic that I added in #57365

Copy link
Member

Choose a reason for hiding this comment

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

This computation happens for every export. I also wonder, why is this necessary? can you explain? i.e. why do we need to extract the "imported" symbols and returning them as symbols here is a bit ambiguous I feel like.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a comment, let me know if it makes it more clear for you.

@devversion
Copy link
Member

I like the general approach, but I also don't know how it was done before in the early versions of angular.dev, or why we stopped/reverted the logic, so I will defer to @jelbourn on this for now.

@devversion devversion requested a review from jelbourn August 14, 2024 12:32
@JeanMeche JeanMeche force-pushed the adev/symbol-links branch 7 times, most recently from f2b9887 to 04769fa Compare August 16, 2024 22:20
@JeanMeche JeanMeche changed the title docs(docs-infra): Add links to other symbols in the API docs docs(docs-infra): Add cross-links to API pages Aug 16, 2024
@JeanMeche JeanMeche force-pushed the adev/symbol-links branch 5 times, most recently from bbc06cf to 39a8441 Compare August 18, 2024 18:38
@JeanMeche JeanMeche requested review from josephperrott and removed request for AndrewKushnir, alxhub and thePunderWoman August 19, 2024 11:37
@JeanMeche JeanMeche force-pushed the adev/symbol-links branch 7 times, most recently from 7b52fd0 to 2b0993a Compare August 19, 2024 15:28
@josephperrott josephperrott removed their request for review August 19, 2024 16:02
@josephperrott
Copy link
Member

Deferring to other reviewers for this specific change.

@JeanMeche
Copy link
Member Author

Currently trying to reduce the scope of this PR, as it might feel a bit large.
I think the important part are the compiler-cli changes.

Copy link
Contributor

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

I got part of the way through before I need to run for the day, but here's my initial comments

Not sure if you were planning to do this already once you got an okay on the approach, but I'll mention anyway: we should split this change up into more granular commits. In particular:

  • Separating the symbol collection into its own commit (and this also needs tests)
  • Changing the representation of class inheritance in its own commit
  • Minimum necessary changes to the renderer to accomodate any DocEntry structure changes
  • Further changes to surface the links in the rendered output

@JeanMeche
Copy link
Member Author

JeanMeche commented Aug 21, 2024

I splitted the changes accross multiple commits, I should ease the review of all the changes (or we can spin them off in other PRs)

I'll add the missings tests for the API extraction when I can.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jelbourn Do you think we should do this concatenation during extraction ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't feel strongly either way

Copy link
Contributor

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

Overall looks good

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't feel strongly either way

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this regex valid? When I try it in a couple of different regex visualizers, it fails. Maybe they can't handle this much lookahead?

At the very least it would be good to add a comment that explains the regex at a high level

Copy link
Member Author

Choose a reason for hiding this comment

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

It is valid, make sure that the visualizer supports ES regex, like https://regex101.com/

Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

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

LGTM, great work! Minor comments in the compiler

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (moduleSpecifier.startsWith('@angular')) {
if (moduleSpecifier.startsWith('@angular/')) {

Copy link
Member

Choose a reason for hiding this comment

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

would it be better/more generic if we filter everything that is not a relative path?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would also expose symbols from RxJS, which is not wanted.

Copy link
Member

Choose a reason for hiding this comment

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

It might be the responsibility of the "consumer" of the symbols list to filter out items that cannot be rendered. Or even cooler, we could link to the RxJS docs that way 😄

@AndrewKushnir
Copy link
Contributor

@JeanMeche there is a conflict with the main branch. Could you please rebase and resolve the merge conflict when you get a chance? Thank you.

This commit changes the structure of the API extraction files to include all symbols used inside a package.

The structure is a `Map`, Symbol => package
eg: 'ApplicationRef' => '@angular/core'
@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 01030d5.

The changes were merged into the following branches: main, 18.2.x

@angular-automatic-lock-bot
Copy link

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.

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 Related to the documentation area: docs-infra Angular.dev application and infrastructure target: patch This PR is targeted for the next patch release

Projects

None yet

5 participants