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

feat(dgeni): render API source block #3385

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

griest024
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Fixes: #3306

What is the new behavior?

One of the major outstanding issues with this is that the dgeni TS package doesn't correctly infer types of everything that TS can. For example, injection tokens and providers that are destructured from the factory function are untyped. Functions that do not have explicit return annotations have untyped return types even when TS correctly infers the return type.

Some of the consts that are function do have some of their type correctly inferred though.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

xelaint and others added 6 commits December 26, 2024 09:10
The link tag will bleed into other parts of the content without being rendered. Instead, directly render symbols to anchors. This will later allow us to easily change how these symbols are rendered, e.g. as an angular router link.
@griest024
Copy link
Member Author

@xelaint @damienwebdev this is ready to preview and give feedback

@xelaint
Copy link
Member

xelaint commented Dec 31, 2024

Is it possible to make the individual properties within the source block linkable to the properties section? When a user is on a page with a long source block section (i.e. /docs/api/cart/state/DaffCartFacade), the individual properties take a while to scroll to.

@@ -2,5 +2,7 @@
<h1>{$ doc.name $}</h1>
{% endblock %}
<p>{$ doc.description $}</p>
<h2>API</h2>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's necessary to have this heading?

Copy link
Member Author

Choose a reason for hiding this comment

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

While I'm not attached to this specific heading, I think some separator between the description and the source block is necessary. When the descriptions includes some code blocks at the end (which is fairly common), I think its not immediately apparent that the source block is not part of the description. See /docs/api/auth/state/daffAuthProvideUnauthenticatedHooks:
image

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I agree there should be a separator then. Is the providers code block a usage example? If so, I think we should also label it as usage example as well, or split up usage example and api into tabs like how angular does it?

Copy link
Member Author

@griest024 griest024 Dec 31, 2024

Choose a reason for hiding this comment

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

yes the provider block is a usage example. I agree, we should tag it as @example and render it separately (tabs sound good)

Copy link
Member

Choose a reason for hiding this comment

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

yes the provider block is a usage example. I agree, we should tag it as @example and render it separately (tabs sound good)

Sounds good. @damienwebdev likes the idea of tabs as well.

@griest024
Copy link
Member Author

Is it possible to make the individual properties within the source block linkable to the properties section? When a user is on a page with a long source block section (i.e. /docs/api/cart/state/DaffCartFacade), the individual properties take a while to scroll to.

yes this is my eventual goal. I'm not sure if it should be in this PR though since it will require changes to how the properties are laid out

@xelaint
Copy link
Member

xelaint commented Dec 31, 2024

Do we need to render the API blocks for design?

Screen Shot 2024-12-31 at 11 04 05 AM

@griest024
Copy link
Member Author

Do we need to render the API blocks for design?

I like them but I'll leave the final decision up to you and @damienwebdev. I have them here mostly as an example of what the source blocks will look like for components.

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.

[FEAT] Source-style API symbol page
2 participants