Skip to content

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

Merged
merged 6 commits into from
May 21, 2020

Conversation

annieyw
Copy link
Contributor

@annieyw annieyw commented May 15, 2020

Add functionality to extract regions from component example source to display as snippets on docs site.

@annieyw annieyw requested review from jelbourn and a team as code owners May 15, 2020 20:22
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 15, 2020
# 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
Copy link
Contributor

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 :)

Copy link
Member

@devversion devversion May 16, 2020

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:]
Copy link
Contributor

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

Copy link
Member

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.

# 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
Copy link
Member

@devversion devversion May 16, 2020

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:]
Copy link
Member

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.

@annieyw
Copy link
Contributor Author

annieyw commented May 18, 2020

Added in more descriptive comments and fixed up region-parser. Will do a followup to rename highlight-files as suggested

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

LGTM

@mmalerba mmalerba added lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels May 20, 2020
@jelbourn jelbourn merged commit bc280f3 into angular:master May 21, 2020
jelbourn pushed a commit that referenced this pull request May 21, 2020
…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]>
@annieyw annieyw deleted the regions branch May 29, 2020 21:32
@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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 29, 2020
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 cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants