-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build(docs): show exported constants in docs #13168
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
Merged
vivian-hu-zz
merged 1 commit into
angular:master
from
devversion:docs/show-exported-constants
Oct 4, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const hljs = require('highlight.js'); | ||
|
||
/** | ||
* Nunjucks extension that supports rendering highlighted content. Content that is placed in | ||
* between a {% highlight %} and {% end_highlight %} block will be automatically highlighted. | ||
* | ||
* HighlightJS cannot detect the code language automatically. Therefore, developers need to | ||
* specify the language manually as first tag-block argument. | ||
*/ | ||
export class HighlightNunjucksExtension { | ||
|
||
/** Tags that will be parsed by this Nunjucks extension. */ | ||
tags = ['highlight']; | ||
|
||
/** Disable autoescaping for content that is rendered within this extension. */ | ||
autoescape = false; | ||
|
||
parse(parser: any, nodes: any) { | ||
const startToken = parser.nextToken(); | ||
const args = parser.parseSignature(null, true); | ||
|
||
// Jump to the end of the "{% highlight }" block. | ||
parser.advanceAfterBlockEnd(startToken.value); | ||
|
||
// Parse text content until {% end_highlight }" has been reached. | ||
const textContent = parser.parseUntilBlocks('end_highlight'); | ||
|
||
// Jump to the end of the "{% highlight }" block. | ||
parser.advanceAfterBlockEnd(); | ||
|
||
return new nodes.CallExtension(this, 'render', args, [textContent]); | ||
} | ||
|
||
render(_context: any, language: string, contentFn: () => string) { | ||
return hljs.highlight(language, contentFn()).value; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% import "macros.html" as macros %} | ||
|
||
<h4 id="{$ constant.name $}" class="docs-header-link docs-api-h4 docs-api-constant-name"> | ||
<span header-link="{$ constant.name $}"></span> | ||
<code>{$ constant.name $}</code> | ||
</h4> | ||
|
||
{%- if constant.isDeprecated -%} | ||
<div class="docs-api-constant-deprecated-marker" {$ macros.deprecationTitle(constant) $}> | ||
Deprecated | ||
</div> | ||
{%- endif -%} | ||
|
||
{%- if constant.description -%} | ||
<p class="docs-api-constant-description">{$ constant.description | marked | safe $}</p> | ||
{%- endif -%} | ||
|
||
<pre class="docs-markdown-pre"> | ||
<code class="docs-markdown-code"> | ||
{%- highlight "typescript" -%} | ||
const {$ constant.name | safe $}: {$ constant.type | safe $} | ||
{%- end_highlight -%} | ||
</code> | ||
</pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use highlightjs here when we don't do this for any of the other symbol types?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I couldn't think of anything that is describing the constant better.
My goal would be to do this for the other types as well (in follow-ups)
This also just looks way better IMO & also describes exports pretty good (besides the description). This is how Angular.io also does it