-
Notifications
You must be signed in to change notification settings - Fork 6.8k
refactor(components-example): extract regions from component example source files #19376
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
Conversation
tools/package-docs-content/index.bzl
Outdated
# Directory that will contain all grouped input files. This directory will be | ||
# created relatively to the current target package. For example: | ||
# "bin/src/components-examples/docs-content/docs-content". The reason we need to | ||
# repeat `docs-content` is for |
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.
ahhhh! What's the reason? Please help :)
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.
Yeah, we should complete that comment (that was actually my bad; I sent an incomplete patch). It's basically the same issue as mentioned in my first review comment. We should link those together by referring to a dedicated JIRA I guess.
Reasoning for putting the docs-content into another docs-content
folder is that the ng_package
rule does not properly handle tree artifacts in data
. The trick is that we create a tree artifact that can be put into nested_packages
. Nested packages do not preserve the tree artifact name (i.e. the directory name), so all contents of the docs-content would be put directly into the @angular/components-examples
package. We don't want that, but preserve the docs-content/
folder. So we have another folder like docs-content
in the tree artifact that is preserved as content of the tree artifact. Not really nice, but unfortunately needed.
section_relative_file_name = input_file.short_path[len(base_dir):] | ||
# path in docs content. e.g. `/docs-content/overviews/cdk/src/cdk/a11y/a11y.html`. Instead, | ||
# we want the path to be: `/docs-content/overviews/cdk/a11y/a11y.html`. | ||
section_relative_file_name = input_file.short_path[len(base_dir) + 1:] |
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.
Hmm, can you explain what this change was for? The comment isn't changed so I'm curious what this was about
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.
Previously, we declared outputs on a per-file basis in Bazel as we knew what outputs to expect from a set of input files. This does no longer work, now that input file could also be a Bazel tree artifact. For those we cannot determine outputs at Bazel analysis time.
We fix this (in a Bazel idiomatic way), by not declaring outputs per-file, but rather by creating a single tree artifact output (see declare_directory
) that can hold arbitrary files. Due to this, we can remove the declare_file
code here.
tools/package-docs-content/index.bzl
Outdated
# Directory that will contain all grouped input files. This directory will be | ||
# created relatively to the current target package. For example: | ||
# "bin/src/components-examples/docs-content/docs-content". The reason we need to | ||
# repeat `docs-content` is for |
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.
Yeah, we should complete that comment (that was actually my bad; I sent an incomplete patch). It's basically the same issue as mentioned in my first review comment. We should link those together by referring to a dedicated JIRA I guess.
Reasoning for putting the docs-content into another docs-content
folder is that the ng_package
rule does not properly handle tree artifacts in data
. The trick is that we create a tree artifact that can be put into nested_packages
. Nested packages do not preserve the tree artifact name (i.e. the directory name), so all contents of the docs-content would be put directly into the @angular/components-examples
package. We don't want that, but preserve the docs-content/
folder. So we have another folder like docs-content
in the tree artifact that is preserved as content of the tree artifact. Not really nice, but unfortunately needed.
section_relative_file_name = input_file.short_path[len(base_dir):] | ||
# path in docs content. e.g. `/docs-content/overviews/cdk/src/cdk/a11y/a11y.html`. Instead, | ||
# we want the path to be: `/docs-content/overviews/cdk/a11y/a11y.html`. | ||
section_relative_file_name = input_file.short_path[len(base_dir) + 1:] |
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.
Previously, we declared outputs on a per-file basis in Bazel as we knew what outputs to expect from a set of input files. This does no longer work, now that input file could also be a Bazel tree artifact. For those we cannot determine outputs at Bazel analysis time.
We fix this (in a Bazel idiomatic way), by not declaring outputs per-file, but rather by creating a single tree artifact output (see declare_directory
) that can hold arbitrary files. Due to this, we can remove the declare_file
code here.
Added in more descriptive comments and fixed up |
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.
LGTM
…source files (#19376) * refactor: functionality to extract regions from component example source files * add README for region-parser * lint issues * add more descriptive comments for changes in bazel * calculate file extension from base path instead of passing it in * remove expanded field Co-authored-by: Annie Wang <[email protected]>
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Add functionality to extract regions from component example source to display as snippets on docs site.