Skip to content
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

adding slash to gen.go links for seo reasons #11569

Merged
merged 4 commits into from Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions pkg/codegen/docs/gen.go
Expand Up @@ -592,11 +592,11 @@ func (mod *modContext) typeString(t schema.Type, lang string, characteristics pr
case *schema.ObjectType:
tokenName := tokenToName(t.Token)
// Links to anchor tags on the same page must be lower-cased.
href = "#" + strings.ToLower(tokenName)
href = "#" + strings.ToLower(tokenName) + "/"
case *schema.EnumType:
tokenName := tokenToName(t.Token)
// Links to anchor tags on the same page must be lower-cased.
href = "#" + strings.ToLower(tokenName)
href = "#" + strings.ToLower(tokenName) + "/"
case *schema.UnionType:
var elements []string
for _, e := range t.ElementTypes {
Expand Down Expand Up @@ -797,7 +797,7 @@ func (mod *modContext) genConstructorCS(r *schema.Resource, argsOptional bool) [
DefaultValue: argsDefault,
Type: propertyType{
Name: name + "Args",
Link: "#inputs",
Link: "#inputs/",
},
Comment: ctorArgsArgComment,
},
Expand Down Expand Up @@ -849,7 +849,7 @@ func (mod *modContext) genConstructorJava(r *schema.Resource, argsOverload bool)
Name: "args",
Type: propertyType{
Name: name + "Args",
Link: "#inputs",
Link: "#inputs/",
},
Comment: ctorArgsArgComment,
},
Expand Down Expand Up @@ -914,7 +914,7 @@ func (mod *modContext) genConstructorPython(r *schema.Resource, argsOptional, ar
Type: propertyType{
Name: typeName,
DescriptionName: descriptionName,
Link: "#inputs",
Link: "#inputs/",
susanev marked this conversation as resolved.
Show resolved Hide resolved
},
Comment: ctorArgsArgComment,
})
Expand Down Expand Up @@ -1113,7 +1113,7 @@ func (mod *modContext) getPropertiesWithIDPrefixAndExclude(properties []*schema.
// a) we will force the replace at the engine level
// b) we are told that the provider will require a replace
IsReplaceOnChanges: prop.ReplaceOnChanges || prop.WillReplaceOnChanges,
Link: "#" + propID,
Link: "#" + propID + "/",
Types: propTypes,
})
}
Expand Down Expand Up @@ -1580,7 +1580,7 @@ func (mod *modContext) genResource(r *schema.Resource) resourceDocArgs {
for i := 0; i < len(stateProps); i++ {
id := "state_" + stateProps[i].ID
stateProps[i].ID = id
stateProps[i].Link = "#" + id
stateProps[i].Link = "#" + id + "/"
}
stateInputs[lang] = stateProps
}
Expand Down Expand Up @@ -1836,7 +1836,7 @@ func (mod *modContext) genIndex() indexData {
modName := mod.getModuleFileName()
displayName := modFilenameToDisplayName(modName)
modules = append(modules, indexEntry{
Link: getModuleLink(displayName),
Link: getModuleLink(displayName) + "/",
DisplayName: displayName,
})
}
Expand All @@ -1846,7 +1846,7 @@ func (mod *modContext) genIndex() indexData {
for _, r := range mod.resources {
name := resourceName(r)
resources = append(resources, indexEntry{
Link: getResourceLink(name),
Link: getResourceLink(name) + "/",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm tempted to say this should be some kind of conditional that checks whether there's already a trailing slash (defense in depth and all that), and that should probably occur within the getResourceLink function.

Just my 2c. 🪙 It's late here, otherwise I'd offer a more concrete suggestion, apologies! I'll revisit tomorrow during work hours when I triage my notifications.

Copy link
Contributor Author

@susanev susanev Dec 8, 2022

Choose a reason for hiding this comment

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

would you be okay with that change happening after this pr lands? I'm happy to revisit this in more detail later on if you'd be up for pairing.

right now none of the resources and function links end in slashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there's prolly some other issues in this file as well if we want to go with your suggested approach, specifically with anchors getting the octothorpe added in this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me!

DisplayName: name,
})
}
Expand All @@ -1856,7 +1856,7 @@ func (mod *modContext) genIndex() indexData {
for _, f := range mod.functions {
name := tokenToName(f.Token)
functions = append(functions, indexEntry{
Link: getFunctionLink(name),
Link: getFunctionLink(name) + "/",
DisplayName: strings.Title(name),
})
}
Expand Down
Expand Up @@ -13,12 +13,12 @@ A native Pulumi package for creating and managing Azure resources.

<h2 id="modules">Modules</h2>
<ul class="api">
<li><a href="documentdb/" title="documentdb"><span class="api-symbol api-symbol--module"></span>documentdb</a></li>
<li><a href="documentdb//" title="documentdb"><span class="api-symbol api-symbol--module"></span>documentdb</a></li>
susanev marked this conversation as resolved.
Show resolved Hide resolved
</ul>

<h2 id="resources">Resources</h2>
<ul class="api">
<li><a href="provider" title="Provider"><span class="api-symbol api-symbol--resource"></span>Provider</a></li>
<li><a href="provider/" title="Provider"><span class="api-symbol api-symbol--resource"></span>Provider</a></li>
</ul>

<h2 id="package-details">Package Details</h2>
Expand Down
Expand Up @@ -13,7 +13,7 @@ Explore the resources and functions of the azure-native.documentdb module.

<h2 id="resources">Resources</h2>
<ul class="api">
<li><a href="sqlresourcesqlcontainer" title="SqlResourceSqlContainer"><span class="api-symbol api-symbol--resource"></span>SqlResourceSqlContainer</a></li>
<li><a href="sqlresourcesqlcontainer/" title="SqlResourceSqlContainer"><span class="api-symbol api-symbol--resource"></span>SqlResourceSqlContainer</a></li>
</ul>

<h2 id="package-details">Package Details</h2>
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -34,7 +34,7 @@ no_edit_this_page: true
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions">Optional[ResourceOptions]</a></span> = None<span class="p">)</span>
<span class=nd>@overload</span>
<span class="k">def </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">resource_name</span><span class="p">:</span> <span class="nx">str</span><span class="p">,</span>
<span class="nx">args</span><span class="p">:</span> <span class="nx"><a href="#inputs">Optional[ProviderArgs]</a></span> = None<span class="p">,</span>
<span class="nx">args</span><span class="p">:</span> <span class="nx"><a href="#inputs/">Optional[ProviderArgs]</a></span> = None<span class="p">,</span>
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions">Optional[ResourceOptions]</a></span> = None<span class="p">)</span></code></pre></div>
</pulumi-choosable>
</div>
Expand All @@ -47,15 +47,15 @@ no_edit_this_page: true

<div>
<pulumi-choosable type="language" values="csharp">
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">public </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">string</span><span class="p"> </span><span class="nx">name<span class="p">,</span> <span class="nx"><a href="#inputs">ProviderArgs</a></span><span class="p">? </span><span class="nx">args = null<span class="p">,</span> <span class="nx"><a href="/docs/reference/pkg/dotnet/Pulumi/Pulumi.CustomResourceOptions.html">CustomResourceOptions</a></span><span class="p">? </span><span class="nx">opts = null<span class="p">)</span></code></pre></div>
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">public </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">string</span><span class="p"> </span><span class="nx">name<span class="p">,</span> <span class="nx"><a href="#inputs/">ProviderArgs</a></span><span class="p">? </span><span class="nx">args = null<span class="p">,</span> <span class="nx"><a href="/docs/reference/pkg/dotnet/Pulumi/Pulumi.CustomResourceOptions.html">CustomResourceOptions</a></span><span class="p">? </span><span class="nx">opts = null<span class="p">)</span></code></pre></div>
</pulumi-choosable>
</div>

<div>
<pulumi-choosable type="language" values="java">
<div class="highlight"><pre class="chroma">
<code class="language-java" data-lang="java"><span class="k">public </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">String</span><span class="p"> </span><span class="nx">name<span class="p">,</span> <span class="nx"><a href="#inputs">ProviderArgs</a></span><span class="p"> </span><span class="nx">args<span class="p">)</span>
<span class="k">public </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">String</span><span class="p"> </span><span class="nx">name<span class="p">,</span> <span class="nx"><a href="#inputs">ProviderArgs</a></span><span class="p"> </span><span class="nx">args<span class="p">,</span> <span class="nx">CustomResourceOptions</span><span class="p"> </span><span class="nx">options<span class="p">)</span>
<code class="language-java" data-lang="java"><span class="k">public </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">String</span><span class="p"> </span><span class="nx">name<span class="p">,</span> <span class="nx"><a href="#inputs/">ProviderArgs</a></span><span class="p"> </span><span class="nx">args<span class="p">)</span>
<span class="k">public </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">String</span><span class="p"> </span><span class="nx">name<span class="p">,</span> <span class="nx"><a href="#inputs/">ProviderArgs</a></span><span class="p"> </span><span class="nx">args<span class="p">,</span> <span class="nx">CustomResourceOptions</span><span class="p"> </span><span class="nx">options<span class="p">)</span>
</code></pre></div>
</pulumi-choosable>
</div>
Expand Down Expand Up @@ -109,7 +109,7 @@ no_edit_this_page: true
class="property-optional" title="Optional">
<span>args</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#inputs">ProviderArgs</a></span>
<span class="property-type"><a href="#inputs/">ProviderArgs</a></span>
</dt>
<dd>The arguments to resource properties.</dd><dt
class="property-optional" title="Optional">
Expand Down Expand Up @@ -167,7 +167,7 @@ no_edit_this_page: true
class="property-optional" title="Optional">
<span>args</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#inputs">ProviderArgs</a></span>
<span class="property-type"><a href="#inputs/">ProviderArgs</a></span>
</dt>
<dd>The arguments to resource properties.</dd><dt
class="property-optional" title="Optional">
Expand All @@ -193,7 +193,7 @@ no_edit_this_page: true
class="property-required" title="Required">
<span>args</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#inputs">ProviderArgs</a></span>
<span class="property-type"><a href="#inputs/">ProviderArgs</a></span>
</dt>
<dd>The arguments to resource properties.</dd><dt
class="property-optional" title="Optional">
Expand Down Expand Up @@ -264,7 +264,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<dl class="resources-properties"><dt class="property-"
title="">
<span id="id_csharp">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_csharp" style="color: inherit; text-decoration: inherit;">Id</a>
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_csharp/" style="color: inherit; text-decoration: inherit;">Id</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
Expand All @@ -279,7 +279,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<dl class="resources-properties"><dt class="property-"
title="">
<span id="id_go">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_go" style="color: inherit; text-decoration: inherit;">Id</a>
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_go/" style="color: inherit; text-decoration: inherit;">Id</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
Expand All @@ -294,7 +294,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<dl class="resources-properties"><dt class="property-"
title="">
<span id="id_java">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_java" style="color: inherit; text-decoration: inherit;">id</a>
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_java/" style="color: inherit; text-decoration: inherit;">id</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">String</span>
Expand All @@ -309,7 +309,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<dl class="resources-properties"><dt class="property-"
title="">
<span id="id_nodejs">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_nodejs" style="color: inherit; text-decoration: inherit;">id</a>
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_nodejs/" style="color: inherit; text-decoration: inherit;">id</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
Expand All @@ -324,7 +324,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<dl class="resources-properties"><dt class="property-"
title="">
<span id="id_python">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_python" style="color: inherit; text-decoration: inherit;">id</a>
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_python/" style="color: inherit; text-decoration: inherit;">id</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">str</span>
Expand All @@ -339,7 +339,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<dl class="resources-properties"><dt class="property-"
title="">
<span id="id_yaml">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_yaml" style="color: inherit; text-decoration: inherit;">id</a>
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#id_yaml/" style="color: inherit; text-decoration: inherit;">id</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">String</span>
Expand Down
Expand Up @@ -13,7 +13,7 @@ no_edit_this_page: true

<h2 id="resources">Resources</h2>
<ul class="api">
<li><a href="provider" title="Provider"><span class="api-symbol api-symbol--resource"></span>Provider</a></li>
<li><a href="provider/" title="Provider"><span class="api-symbol api-symbol--resource"></span>Provider</a></li>
</ul>

<h2 id="package-details">Package Details</h2>
Expand Down