-
Notifications
You must be signed in to change notification settings - Fork 9
feat(ruby): display friendly api name before page title for Ruby docs #367
Conversation
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.
Could you remove the unnecessary files? For the purpose of showing the friendly title, YAML updates are fine but it's containing a bit more than we should need for this PR, making it harder to focus on the necessary changes.
@@ -13,6 +13,7 @@ exports.transform = function (model) { | |||
} | |||
|
|||
model._disableToc = model._disableToc || !model._tocPath || (model._navPath === model._tocPath); | |||
model._displayFriendlyApiName = model._displayFriendlyApiName && model.friendlyApiName |
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.
Since we already have {{#_displayFriendlyApiName}}
in the template, this is a redundant check.
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.
This checks that the friendlyApiName
key in the yaml present and non-empty.
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.
Right, do we need to check that it's present and non-empty for a specific reason? Suppose that this JavaScript line isn't there, if _displayFriendlyApiName
is not present then the template will not render it. That's why I think this is a redundant check, unless there's a reason I'm not aware of.
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.
There's a -
character between the friendly api name and the existing title. If the friendlyApiName
key is missing from the yaml, the dash character will still appear unless we have this additional condition.
d44ce1c
to
99f2b83
Compare
Yes, we can do the updates to the Ruby yaml and golden doc set as a follow-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.
Could you update the goldens? Looks like the slight changes triggered whitespace changes, curious how it look snow.
…gleapis/doc-templates into title-with-friendly-api-name
…gleapis/doc-templates into title-with-friendly-api-name
@@ -1,7 +1,10 @@ | |||
{{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} | |||
{{!master(layout/_master.tmpl)}} | |||
|
|||
<h1 class="page-title">{{#title}}{{title}}{{/title}}{{^title}}{{>partials/title}}{{/title}}</h1> | |||
<h1 class="page-title"> | |||
{{#_displayFriendlyApiName}} |
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.
I don't think we need _displayFriendlyApiName
. Values are truthy in the template. So, we should just be able to do
{{#friendlyApiName}}
{{friendlyApiName}}
{{/friendlyApiName}}
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.
I was hoping to have a flag, _displayFriendlyApiName
, to either enable or disable this change from doc-pipeline. Ruby libraries are already generating yaml with the friendlyApiName
key so updating the template would effectively make this change live on prod for at least some Ruby libraries. However, I think just relying on the friendlyApiName
key (and not changing the docfx JSON) is okay too as this is a pretty safe change. Wdyt?
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.
To disable this experiment, we can remove this from the template, or "turn off" them on docfx.json. At the moment because there is no experiment structure they're equivalent (as in a PR for deleting/changing in this repo). In that case I'd prefer to have the template only contain what's necessary rather than leaving this behind and possibly forgetting this later on.
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.
That's a good point, we can just use the friendlyApiName
key directly then.
c0eb7a3
to
569f0cc
Compare
569f0cc
to
d7470a6
Compare
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.
testdata/goldens/go/index.html
Outdated
@@ -8,7 +8,9 @@ | |||
{% verbatim %} | |||
<div> | |||
<article data-uid="cloud.google.com/go/storage"> | |||
<h1 class="page-title">Package cloud.google.com/go/storage | |||
<h1 class="page-title"> |
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.
Any way we can avoid these whitespace changes? This would modify every file. Would be nice not to. Fine if not.
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.
Yes, if we keep it all in one line in the template, but it's slightly less readable:
<h1 class="page-title">{{#friendlyApiName}}{{friendlyApiName}} - {{/friendlyApiName}}{{#title}}{{title}}{{/title}}{{^title}}{{>partials/title}}{{/title}}</h1>
Wdyt?
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.
That is pretty intense to read. So, let's leave it as-is.
* factor out setting property type * factor out property type name from ManagedReference pre-renderer * remove dependency on partials/title * modify to access first element in name * edit title in common.js based on type * chore: write title in preprocessor instead of partial template * fix minor bugs, add new line on </h1> to match golden * fix: use model type instead of javaType, loosen title restriction in template * fix: remove newline in <h1>, document getTitleForTypeProperty function Co-authored-by: Dan Lee <[email protected]>
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [google-cloud-storage](https://togithub.com/googleapis/python-storage) | `~=2.2.0` -> `~=2.3.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.3.0/compatibility-slim/2.2.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.3.0/confidence-slim/2.2.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>googleapis/python-storage</summary> ### [`v2.3.0`](https://togithub.com/googleapis/python-storage/blob/HEAD/CHANGELOG.md#​230-httpsgithubcomgoogleapispython-storagecomparev221v230-2022-04-12) [Compare Source](https://togithub.com/googleapis/python-storage/compare/v2.2.1...v2.3.0) ##### Features - add dual region bucket support and sample ([#​748](https://togithub.com/googleapis/python-storage/issues/748)) ([752e8ab](https://togithub.com/googleapis/python-storage/commit/752e8ab42d23afd68738e4d7ca6cdeee416dfd50)) - track invocation id for retry metrics ([#​741](https://togithub.com/googleapis/python-storage/issues/741)) ([bd56931](https://togithub.com/googleapis/python-storage/commit/bd5693164e7331df5f14186fd002e72e5203d7ee)) ##### Bug Fixes - **deps:** drop pkg_resources ([#​744](https://togithub.com/googleapis/python-storage/issues/744)) ([e963f33](https://togithub.com/googleapis/python-storage/commit/e963f33ced2852b64d721d69928b54443461ec9c)) ##### Documentation - fix links in blob module ([#​759](https://togithub.com/googleapis/python-storage/issues/759)) ([9b29314](https://togithub.com/googleapis/python-storage/commit/9b2931430b0796ffb23ec4efacd82dacad36f40f)) ##### [2.2.1](https://togithub.com/googleapis/python-storage/compare/v2.2.0...v2.2.1) (2022-03-15) ##### Bug Fixes - remove py.typed marker file for PEP 561 ([#​735](https://togithub.com/googleapis/python-storage/issues/735)) ([f77d2f7](https://togithub.com/googleapis/python-storage/commit/f77d2f787f435f2f898e9babcdab81225672ad4f)), closes [#​734](https://togithub.com/googleapis/python-storage/issues/734) </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/doc-templates).
This change modifies the template to prepend the "friendlyApiName" in the
<h1>
of generated pages. This also updates the Ruby test yaml and accompanying golden doc set.