Add ToC Generation script and wire up to docindex.yml#19915
Add ToC Generation script and wire up to docindex.yml#19915danieljurek merged 7 commits intomainfrom
Conversation
|
|
||
| # Map metadata to package. Validate metadata entries. | ||
| $packagesForToc = @{} | ||
| foreach ($packageName in $onboardedPackages.Keys) { |
There was a problem hiding this comment.
Not sure how or if it is worth it sharing this but if we do need the same thing for other languages we should add a helper. I also have a similar helper in the azure-sdk repo https://github.com/Azure/azure-sdk/blob/main/eng/scripts/PackageList-Helpers.ps1#L178.
There was a problem hiding this comment.
This looks like it can work. It might make sense to put it in eng/common/scripts though its usage is only scoped to Update-DocsMsToc.ps for now.
There was a problem hiding this comment.
Yeah something under eng-common that builds a look-up table once we have multiple users.
|
Some minor nits otherwise I'll defer to @weshaggard here. |
eng/common/pipelines/templates/steps/set-daily-docs-branch-name.yml
Outdated
Show resolved
Hide resolved
| $packageLevelReadmeName = $packageMetadata.Package.Replace('@azure/', '').Replace('@azure-tools/', '').Replace('azure-', ''); | ||
|
|
||
| # Fallback to get package-level readme name if metadata file info does not exist | ||
| if ($packageMetadata.Package.StartsWith('@azure-rest/')) { |
There was a problem hiding this comment.
It is unfortunate that we another place to special case azure-rest. @praveenkuttappan something to look at with your other clean-up of that processing.
weshaggard
left a comment
There was a problem hiding this comment.
Added a few minor clean-up points but once your testing it done it seems good to me.
| if ($otherPackages) { | ||
| foreach ($otherPackage in $otherPackages) { | ||
| $otherPackageItems += GetClientPackageNode $otherPackage | ||
| $segments = $otherPackage.DisplayName.Split(' - ') |
There was a problem hiding this comment.
Should we split only on "-" and then trim any whitespace? Just to make this a little more tolerable to simple typos.
|
|
||
| if ($segments.Count -gt 1) { | ||
| $currentNode = $otherPackageItems | ||
| foreach ($segment in $segments[0..($segments.Count - 2)]) { |
There was a problem hiding this comment.
I know you added the comment to help address this question, but I think I'm still missing something. Maybe give an example of a display name that would illustrates what you are trying to do here.
If I understand correct we might end up with something like "Core - Http" and is the goal that we essentially drop the Http part and because we want that to be a leaf node and not nested node?
There was a problem hiding this comment.
Correct. This loop does not build the leaf nodes. It only builds the branches extending from the "Other" node up to where the leaf should be added.
In the case of DisplayName "Core - Http"
- name: Other
landingPageType: Service
items: # $otherPackages
# Built by the loop
- name: Core
landingPageType: Service
items:
# Added outside of the loop
- name: Http
href: ~/some/md/file.md
children:
- @azure/core-httpIn the case of DisplayName "Core - Client - Http"
- name: Other
landingPageType: Service
items: # $otherPackages
# Built by the loop
- name: Core
landingPageType: Service
items:
# Also built by the loop
- name: Client
landingPageType: Service
items:
# Added outside of the loop
- name: Http
href: ~/some/md/file.md
children:
- @azure/core-http| } | ||
| } | ||
|
|
||
| if ($null -ne $currentNode) { |
There was a problem hiding this comment.
Is it possible to have currentNode be null? If it is wouldn't that be an error which we should probably fail on?
There was a problem hiding this comment.
We set $currentNode to $null when the metadata contains a hypothetical scenario like this:
| Package | DisplayName | ServiceName |
|---|---|---|
| @azure/core-client | Core - Client | Other |
| @azuure/core-xml | Core - Client - XML | Other |
In this case, we would build a node like this for the first:
- name: Core
landingPageType: Service
items:
- name: Client
href: ~/some/markdown/file.md
children:
- @azure/core-client When we attempt to iterate in on the second node we reach Client and see that it is a leaf node (i.e. children instead of items). In this case we break out of that loop but need a way to say "Don't set an items property on this entry in the ToC, it won't work" ... Setting the node to $null is the way to do this.
If we quit the entire process here then we'd end up stopping the ToC update process and blocking on a package because of bad metadata. If we skip a package here that package will still end up in Uncategorized Packages and we'll be able to build the rest of the ToC.
There was a problem hiding this comment.
If we skip a package here that package will still end up in Uncategorized Packages and we'll be able to build the rest of the ToC.
I guess I'm missing where this happens.
Originally proposed here -- Azure/azure-sdk-for-js#19915
5f8a6d4 to
9a1dcba
Compare
|
This pull request is protected by Check Enforcer. What is Check Enforcer?Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass. Why am I getting this message?You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged. What should I do now?If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows: What if I am onboarding a new service?Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment: |
eng/scripts/docs/Docs-ToC.ps1
Outdated
There was a problem hiding this comment.
Is it expected that there would be multiple matches for this in $items?
There was a problem hiding this comment.
There will not be multiple matches for a service in this way given how the ToC is generated from a hashed set of service names.
eng/scripts/docs/Docs-ToC.ps1
Outdated
There was a problem hiding this comment.
Is this intermediate variable necessary since you're just updating by reference? I think it's a little confusing since there are so many nested items properties, vs. just using $toc[$i].items += ... below.
There was a problem hiding this comment.
$items[$i].name is easier to read than $toc[0].items[$i].name when repeated. However, a better name for this intermediate variable is probably $services which applies well enough in this domain.
9a1dcba to
e754ebc
Compare
Add Docs-ToC.ps1 Remove eng/scripts/docs from .gitignore but keep filtering other docs/ folders Also checkout packages-legacy.json in sparse checkout Also check out docs-ref-mapping/ Use -toc-test branch for demo Review feedback Review feedback Remove unnecessary comment Undo working changes Add extension point to update the ToC before output Undo changes to demo set-daily-docs-branch-name.yml Check for FileMetadata before accessing it Add ability to artbitarily nest packages in the 'Other' service. Add comments from review feedback Add plugin nodes
d38cff5 to
f50862f
Compare
Docindex running and producing the ToC -- https://dev.azure.com/azure-sdk/internal/_build/results?buildId=1315921&view=logs&j=dc056dfc-c0cf-5958-c8c4-8da4f91a3739&t=98c76ae6-047b-5869-f98c-bcf6099a854a
Review site with new ToC layout -- https://review.docs.microsoft.com/en-us/javascript/api/overview/azure/?branch=daily%2F2022-01-20-toc-test&view=azure-node-latest
Please have a look at