From b5f5aefe24431ea338f0f95522ef57db08f06ecc Mon Sep 17 00:00:00 2001 From: Jamal Carvalho Date: Tue, 1 Jun 2021 14:00:38 -0400 Subject: [PATCH] content/static: deprecated symbols ui updates Deprecated symbol sections are updated to match UX design. Deprecated sections will expand when navigated to from the index or a direct link. For golang/go#40850 Change-Id: I2108a28d8a4c1655fcad414a239f46605a725673 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/323969 Trust: Jamal Carvalho Run-TryBot: Jamal Carvalho TryBot-Result: kokoro Reviewed-by: Jonathan Amsterdam --- content/static/css/stylesheet.css | 1 + content/static/css/unit_doc.css | 48 +++++-- content/static/html/doc/body.tmpl | 54 ++++---- content/static/js/unit.js | 2 +- content/static/js/unit.js.map | 4 +- content/static/js/unit.ts | 19 +++ .../dochtml/testdata/deprecated-off.golden | 30 +++-- .../dochtml/testdata/deprecated-on.golden | 122 +++++++++++++----- .../godoc/dochtml/testdata/everydecl.golden | 27 ++-- 9 files changed, 216 insertions(+), 91 deletions(-) diff --git a/content/static/css/stylesheet.css b/content/static/css/stylesheet.css index 6d1e00b69..7e16729cd 100644 --- a/content/static/css/stylesheet.css +++ b/content/static/css/stylesheet.css @@ -28,6 +28,7 @@ --slate: #253443; /* Footer background. */ --white: #fff; --yellow: #fddd00; + --yellow-light: #fff8cc; --header-height: 3.5rem; } diff --git a/content/static/css/unit_doc.css b/content/static/css/unit_doc.css index 019baf8b5..828674d2b 100644 --- a/content/static/css/unit_doc.css +++ b/content/static/css/unit_doc.css @@ -299,28 +299,50 @@ } .Documentation-indexDeprecated { - color: var(--gray-3); - font-size: 0.875rem; - font-style: italic; margin-left: 0.5rem; } .Documentation-deprecatedBody { color: var(--gray-3); - font-size: 1rem; - font-style: italic; + font-size: 0.875rem; font-weight: 400; - margin-left: 0.5rem; + margin-left: 0.25rem; margin-right: 0.5rem; } +.Documentation-deprecatedTag { + background-color: var(--gray-6); + border-radius: 0.125rem; + color: var(--white); + font-size: 0.75rem; + font-weight: normal; + line-height: 1.375; + padding: 0.125rem 0.25rem; + text-transform: uppercase; + vertical-align: middle; +} +.Documentation-deprecatedTitle { + align-items: center; + display: flex; + gap: 0.5rem; +} +.Documentation-deprecatedDetails { + color: var(--gray-4); +} +.Documentation-deprecatedDetails a { + color: var(--gray-4); +} +.Documentation-deprecatedDetails[open] { + color: var(--gray-1); +} +.Documentation-deprecatedDetails[open] a { + color: var(--turq-dark); +} .Documentation-deprecatedDetails .Documentation-deprecatedBody::after { color: var(--turq-dark); content: 'Show'; - margin-left: 1rem; } .Documentation-deprecatedDetails[open] .Documentation-deprecatedBody::after { color: var(--turq-dark); content: 'Hide'; - margin-left: 1rem; } .Documentation-deprecatedDetails > summary { list-style: none; @@ -329,3 +351,13 @@ .Documentation-deprecatedDetails .Documentation-source { opacity: 1; } +.Documentation-deprecatedItemBody { + background-color: var(--yellow-light); + padding: 1rem 1rem 0.5rem 1rem; +} +.Documentation-deprecatedMessage { + align-items: center; + display: flex; + gap: 0.5rem; + margin-bottom: 1rem; +} diff --git a/content/static/html/doc/body.tmpl b/content/static/html/doc/body.tmpl index 09900b69e..5e7650557 100644 --- a/content/static/html/doc/body.tmpl +++ b/content/static/html/doc/body.tmpl @@ -21,41 +21,36 @@ {{- range .Funcs -}}
  • - {{render_synopsis .Decl}} + {{render_synopsis .Decl}} {{- if .IsDeprecated -}} - deprecated + deprecated {{- end -}}
  • {{"\n"}} {{- end -}} {{- range .Types -}} {{- $tname := .Name -}} -
  • type {{$tname}} - {{- if .IsDeprecated -}} - deprecated - {{- end -}} -
  • {{"\n"}} +
  • + type {{$tname}} + {{- if .IsDeprecated -}} + deprecated + {{- end -}} +
  • {{"\n"}} {{- with .Funcs -}} -
  • {{"\n" -}} {{- end -}} {{- with .Methods -}} -
  • {{"\n" -}} {{- end -}} {{- end -}} @@ -145,17 +140,24 @@ {{define "item"}} {{$id := safe_id .FullName}} {{if .IsDeprecated}} -
    +

    - - {{.HeaderStart}} {{source_link .Name .Decl}} - deprecated + + {{.HeaderStart}} {{source_link .Name .Decl}} + deprecated + {{- template "since_version" .FullName -}}

    {{"\n"}}
    - {{template "item_body" .}} +
    +
    + + This {{.Kind}} has been deprecated. +
    + {{template "item_body" .}} +
    {{else}}

    diff --git a/content/static/js/unit.js b/content/static/js/unit.js index f14bf9bea..102256d1e 100644 --- a/content/static/js/unit.js +++ b/content/static/js/unit.js @@ -3,5 +3,5 @@ * Copyright 2021 The Go Authors. All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the LICENSE file. - */import{CopyToClipboardController as p}from"./clipboard.js";import"./toggle-tip.js";import{ExpandableRowsTableController as y}from"./table.js";document.querySelectorAll(".js-expandableTable").forEach(e=>new y(e,document.querySelector(".js-expandAllDirectories"))),document.querySelectorAll(".js-copyToClipboard").forEach(e=>{new p(e)});const t=document.querySelector(".js-readme"),o=document.querySelector(".js-readmeContent"),s=document.querySelector(".js-readmeOutline"),d=document.querySelectorAll(".js-readmeExpand"),a=document.querySelector(".js-readmeCollapse"),h=document.querySelector(".DocNavMobile-select");t&&o&&s&&d.length&&a&&(window.location.hash.includes("readme")&&t.classList.add("UnitReadme--expanded"),h?.addEventListener("change",e=>{e.target.value.startsWith("readme-")&&t.classList.add("UnitReadme--expanded")}),d.forEach(e=>e.addEventListener("click",r=>{r.preventDefault(),t.classList.add("UnitReadme--expanded"),t.scrollIntoView()})),a.addEventListener("click",e=>{e.preventDefault(),t.classList.remove("UnitReadme--expanded"),d[1]&&d[1].scrollIntoView({block:"center"})}),o.addEventListener("keyup",()=>{t.classList.add("UnitReadme--expanded")}),o.addEventListener("click",()=>{t.classList.add("UnitReadme--expanded")}),s.addEventListener("click",()=>{t.classList.add("UnitReadme--expanded")}),document.addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&e.key==="f"&&t.classList.add("UnitReadme--expanded")}));const i=document.querySelector(".js-readmeOption");i&&!t&&i.setAttribute("disabled","true");const E=document.querySelector(".js-unitDirectories"),m=document.querySelector(".js-directoriesOption");!E&&m&&m.setAttribute("disabled","true"),document.querySelectorAll(".js-buildContextSelect").forEach(e=>{e.addEventListener("change",r=>{window.location.search=`?GOOS=${r.target.value}`})});const n=document.querySelector(".js-unitHeader");n?.addEventListener("dblclick",e=>{e.target===n.firstElementChild&&n.classList.contains("UnitHeader--sticky")&&(window.getSelection()?.removeAllRanges(),window.scrollTo({top:0}))});const l=document.querySelector(".UnitHeader"),L=l?.querySelector(".UnitHeader-breadcrumbs"),b=l?.querySelector(".UnitHeader-content"),c=()=>{document.documentElement.style.removeProperty("--full-header-height"),document.documentElement.style.setProperty("--full-header-height",`${(l?.getBoundingClientRect().height??0)/16}rem`),document.documentElement.style.setProperty("--banner-height","0rem"),document.documentElement.style.setProperty("--breadcrumbs-height",`${(L?.getBoundingClientRect().height??0)/16}rem`),document.documentElement.style.setProperty("--content-height",`${(b?.getBoundingClientRect().height??0)/16}rem`)};c(),window.addEventListener("resize",function(){c()});const S=new IntersectionObserver(([e])=>{e.intersectionRatio<1?(n?.classList.add("UnitHeader--sticky"),n?.classList.remove("UnitHeader--full")):(n?.classList.remove("UnitHeader--sticky"),n?.classList.add("UnitHeader--full"),c())},{threshold:1,rootMargin:"40px"}),u=document.querySelector(".js-headerSentinel");u&&S.observe(u); + */import{CopyToClipboardController as p}from"./clipboard.js";import"./toggle-tip.js";import{ExpandableRowsTableController as y}from"./table.js";document.querySelectorAll(".js-expandableTable").forEach(e=>new y(e,document.querySelector(".js-expandAllDirectories"))),document.querySelectorAll(".js-copyToClipboard").forEach(e=>{new p(e)});const t=document.querySelector(".js-readme"),l=document.querySelector(".js-readmeContent"),s=document.querySelector(".js-readmeOutline"),o=document.querySelectorAll(".js-readmeExpand"),i=document.querySelector(".js-readmeCollapse"),E=document.querySelector(".DocNavMobile-select");t&&l&&s&&o.length&&i&&(window.location.hash.includes("readme")&&t.classList.add("UnitReadme--expanded"),E?.addEventListener("change",e=>{e.target.value.startsWith("readme-")&&t.classList.add("UnitReadme--expanded")}),o.forEach(e=>e.addEventListener("click",n=>{n.preventDefault(),t.classList.add("UnitReadme--expanded"),t.scrollIntoView()})),i.addEventListener("click",e=>{e.preventDefault(),t.classList.remove("UnitReadme--expanded"),o[1]&&o[1].scrollIntoView({block:"center"})}),l.addEventListener("keyup",()=>{t.classList.add("UnitReadme--expanded")}),l.addEventListener("click",()=>{t.classList.add("UnitReadme--expanded")}),s.addEventListener("click",()=>{t.classList.add("UnitReadme--expanded")}),document.addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&e.key==="f"&&t.classList.add("UnitReadme--expanded")}));for(const e of document.querySelectorAll(".js-deprecatedTagLink")){const n=new URL(e.href).hash,d=document.querySelector(n)?.parentElement?.parentElement;d&&(e.addEventListener("click",()=>{d.open=!0}),location.hash===n&&(d.open=!0))}const m=document.querySelector(".js-readmeOption");m&&!t&&m.setAttribute("disabled","true");const L=document.querySelector(".js-unitDirectories"),u=document.querySelector(".js-directoriesOption");!L&&u&&u.setAttribute("disabled","true"),document.querySelectorAll(".js-buildContextSelect").forEach(e=>{e.addEventListener("change",n=>{window.location.search=`?GOOS=${n.target.value}`})});const r=document.querySelector(".js-unitHeader");r?.addEventListener("dblclick",e=>{e.target===r.firstElementChild&&r.classList.contains("UnitHeader--sticky")&&(window.getSelection()?.removeAllRanges(),window.scrollTo({top:0}))});const c=document.querySelector(".UnitHeader"),f=c?.querySelector(".UnitHeader-breadcrumbs"),g=c?.querySelector(".UnitHeader-content"),a=()=>{document.documentElement.style.removeProperty("--full-header-height"),document.documentElement.style.setProperty("--full-header-height",`${(c?.getBoundingClientRect().height??0)/16}rem`),document.documentElement.style.setProperty("--banner-height","0rem"),document.documentElement.style.setProperty("--breadcrumbs-height",`${(f?.getBoundingClientRect().height??0)/16}rem`),document.documentElement.style.setProperty("--content-height",`${(g?.getBoundingClientRect().height??0)/16}rem`)};a(),window.addEventListener("resize",function(){a()});const S=new IntersectionObserver(([e])=>{e.intersectionRatio<1?(r?.classList.add("UnitHeader--sticky"),r?.classList.remove("UnitHeader--full")):(r?.classList.remove("UnitHeader--sticky"),r?.classList.add("UnitHeader--full"),a())},{threshold:1,rootMargin:"40px"}),h=document.querySelector(".js-headerSentinel");h&&S.observe(h); //# sourceMappingURL=unit.js.map diff --git a/content/static/js/unit.js.map b/content/static/js/unit.js.map index 5d1af863f..a4ed7cf17 100644 --- a/content/static/js/unit.js.map +++ b/content/static/js/unit.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["unit.ts"], - "sourcesContent": ["/*!\n * @license\n * Copyright 2021 The Go Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\nimport { CopyToClipboardController } from './clipboard.js';\nimport './toggle-tip.js';\nimport { ExpandableRowsTableController } from './table.js';\n\ndocument\n .querySelectorAll('.js-expandableTable')\n .forEach(\n el =>\n new ExpandableRowsTableController(\n el,\n document.querySelector('.js-expandAllDirectories')\n )\n );\n\n/**\n * Instantiates CopyToClipboardController controller copy buttons\n * on the unit page.\n */\ndocument.querySelectorAll('.js-copyToClipboard').forEach(el => {\n new CopyToClipboardController(el);\n});\n\n/**\n * Event handlers for expanding and collapsing the readme section.\n */\nconst readme = document.querySelector('.js-readme');\nconst readmeContent = document.querySelector('.js-readmeContent');\nconst readmeOutline = document.querySelector('.js-readmeOutline');\nconst readmeExpand = document.querySelectorAll('.js-readmeExpand');\nconst readmeCollapse = document.querySelector('.js-readmeCollapse');\nconst mobileNavSelect = document.querySelector('.DocNavMobile-select');\nif (readme && readmeContent && readmeOutline && readmeExpand.length && readmeCollapse) {\n if (window.location.hash.includes('readme')) {\n readme.classList.add('UnitReadme--expanded');\n }\n mobileNavSelect?.addEventListener('change', e => {\n if ((e.target as HTMLSelectElement).value.startsWith('readme-')) {\n readme.classList.add('UnitReadme--expanded');\n }\n });\n readmeExpand.forEach(el =>\n el.addEventListener('click', e => {\n e.preventDefault();\n readme.classList.add('UnitReadme--expanded');\n readme.scrollIntoView();\n })\n );\n readmeCollapse.addEventListener('click', e => {\n e.preventDefault();\n readme.classList.remove('UnitReadme--expanded');\n if (readmeExpand[1]) {\n readmeExpand[1].scrollIntoView({ block: 'center' });\n }\n });\n readmeContent.addEventListener('keyup', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n readmeContent.addEventListener('click', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n readmeOutline.addEventListener('click', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n document.addEventListener('keydown', e => {\n if ((e.ctrlKey || e.metaKey) && e.key === 'f') {\n readme.classList.add('UnitReadme--expanded');\n }\n });\n}\n\n/**\n * Disable unavailable sections in navigation dropdown on mobile.\n */\nconst readmeOption = document.querySelector('.js-readmeOption');\nif (readmeOption && !readme) {\n readmeOption.setAttribute('disabled', 'true');\n}\nconst unitDirectories = document.querySelector('.js-unitDirectories');\nconst directoriesOption = document.querySelector('.js-directoriesOption');\nif (!unitDirectories && directoriesOption) {\n directoriesOption.setAttribute('disabled', 'true');\n}\ndocument.querySelectorAll('.js-buildContextSelect').forEach(el => {\n el.addEventListener('change', e => {\n window.location.search = `?GOOS=${(e.target as HTMLSelectElement).value}`;\n });\n});\n\n/**\n * Adds double click event listener to the header that will\n * scroll the page back to the top.\n */\nconst unitHeader = document.querySelector('.js-unitHeader');\nunitHeader?.addEventListener('dblclick', e => {\n const target = e.target as HTMLElement;\n if (\n target === unitHeader.firstElementChild &&\n unitHeader.classList.contains('UnitHeader--sticky')\n ) {\n window.getSelection()?.removeAllRanges();\n window.scrollTo({ top: 0 });\n }\n});\n\n/**\n * Calculates dynamic heights values for header elements to support\n * variable size sticky positioned elements in the header so that banners\n * and breadcumbs may overflow to multiple lines.\n */\nconst header = document.querySelector('.UnitHeader');\nconst breadcrumbs = header?.querySelector('.UnitHeader-breadcrumbs');\nconst content = header?.querySelector('.UnitHeader-content');\nconst calcSize = () => {\n document.documentElement.style.removeProperty('--full-header-height');\n document.documentElement.style.setProperty(\n '--full-header-height',\n `${(header?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n document.documentElement.style.setProperty('--banner-height', `0rem`);\n document.documentElement.style.setProperty(\n '--breadcrumbs-height',\n `${(breadcrumbs?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n document.documentElement.style.setProperty(\n '--content-height',\n `${(content?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n};\ncalcSize();\nwindow.addEventListener('resize', function () {\n calcSize();\n});\n\n/**\n * Observer for header that applies classnames to transition\n * header elements into their sticky position and back into the\n * full size position.\n */\nconst observer = new IntersectionObserver(\n ([e]) => {\n if (e.intersectionRatio < 1) {\n unitHeader?.classList.add('UnitHeader--sticky');\n unitHeader?.classList.remove('UnitHeader--full');\n } else {\n unitHeader?.classList.remove('UnitHeader--sticky');\n unitHeader?.classList.add('UnitHeader--full');\n calcSize();\n }\n },\n { threshold: 1.0, rootMargin: '40px' }\n);\n\nconst headerSentinel = document.querySelector('.js-headerSentinel');\nif (headerSentinel) {\n observer.observe(headerSentinel);\n}\n"], - "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAOA,2DACA,wBACA,2DAEA,SACG,iBAAmC,uBACnC,QACC,GACE,GAAI,GACF,EACA,SAAS,cAAiC,8BAQlD,SAAS,iBAAoC,uBAAuB,QAAQ,GAAM,CAChF,GAAI,GAA0B,KAMhC,KAAM,GAAS,SAAS,cAAc,cAChC,EAAgB,SAAS,cAAc,qBACvC,EAAgB,SAAS,cAAc,qBACvC,EAAe,SAAS,iBAAiB,oBACzC,EAAiB,SAAS,cAAc,sBACxC,EAAkB,SAAS,cAAiC,wBAClE,AAAI,GAAU,GAAiB,GAAiB,EAAa,QAAU,GACjE,QAAO,SAAS,KAAK,SAAS,WAChC,EAAO,UAAU,IAAI,wBAEvB,GAAiB,iBAAiB,SAAU,GAAK,CAC/C,AAAK,EAAE,OAA6B,MAAM,WAAW,YACnD,EAAO,UAAU,IAAI,0BAGzB,EAAa,QAAQ,GACnB,EAAG,iBAAiB,QAAS,GAAK,CAChC,EAAE,iBACF,EAAO,UAAU,IAAI,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wB,QAAU,GAAK,SAE1D,SAAS,gBAAgB,MAAM,YAC7B,mBACA,GAAI,IAAS,wBAAwB,QAAU,GAAK,UAGxD,IACA,OAAO,iBAAiB,SAAU,UAAY,CAC5C,MAQF,KAAM,GAAW,GAAI,sBACnB,CAAC,CAAC,KAAO,CACP,AAAI,EAAE,kBAAoB,EACxB,IAAY,UAAU,IAAI,sBAC1B,GAAY,UAAU,OAAO,qBAE7B,IAAY,UAAU,OAAO,sBAC7B,GAAY,UAAU,IAAI,oBAC1B,MAGJ,CAAE,UAAW,EAAK,WAAY,SAG1B,EAAiB,SAAS,cAAc,sBAC9C,AAAI,GACF,EAAS,QAAQ", + "sourcesContent": ["/*!\n * @license\n * Copyright 2021 The Go Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\nimport { CopyToClipboardController } from './clipboard.js';\nimport './toggle-tip.js';\nimport { ExpandableRowsTableController } from './table.js';\n\ndocument\n .querySelectorAll('.js-expandableTable')\n .forEach(\n el =>\n new ExpandableRowsTableController(\n el,\n document.querySelector('.js-expandAllDirectories')\n )\n );\n\n/**\n * Instantiates CopyToClipboardController controller copy buttons\n * on the unit page.\n */\ndocument.querySelectorAll('.js-copyToClipboard').forEach(el => {\n new CopyToClipboardController(el);\n});\n\n/**\n * Event handlers for expanding and collapsing the readme section.\n */\nconst readme = document.querySelector('.js-readme');\nconst readmeContent = document.querySelector('.js-readmeContent');\nconst readmeOutline = document.querySelector('.js-readmeOutline');\nconst readmeExpand = document.querySelectorAll('.js-readmeExpand');\nconst readmeCollapse = document.querySelector('.js-readmeCollapse');\nconst mobileNavSelect = document.querySelector('.DocNavMobile-select');\nif (readme && readmeContent && readmeOutline && readmeExpand.length && readmeCollapse) {\n if (window.location.hash.includes('readme')) {\n readme.classList.add('UnitReadme--expanded');\n }\n mobileNavSelect?.addEventListener('change', e => {\n if ((e.target as HTMLSelectElement).value.startsWith('readme-')) {\n readme.classList.add('UnitReadme--expanded');\n }\n });\n readmeExpand.forEach(el =>\n el.addEventListener('click', e => {\n e.preventDefault();\n readme.classList.add('UnitReadme--expanded');\n readme.scrollIntoView();\n })\n );\n readmeCollapse.addEventListener('click', e => {\n e.preventDefault();\n readme.classList.remove('UnitReadme--expanded');\n if (readmeExpand[1]) {\n readmeExpand[1].scrollIntoView({ block: 'center' });\n }\n });\n readmeContent.addEventListener('keyup', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n readmeContent.addEventListener('click', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n readmeOutline.addEventListener('click', () => {\n readme.classList.add('UnitReadme--expanded');\n });\n document.addEventListener('keydown', e => {\n if ((e.ctrlKey || e.metaKey) && e.key === 'f') {\n readme.classList.add('UnitReadme--expanded');\n }\n });\n}\n\n/**\n * Expand details items that are focused. This will expand\n * deprecated symbols when they are navigated to from the index\n * or a direct link.\n */\nfor (const a of document.querySelectorAll('.js-deprecatedTagLink')) {\n const hash = new URL(a.href).hash;\n const heading = document.querySelector(hash);\n const details = heading?.parentElement?.parentElement as HTMLDetailsElement | null;\n if (details) {\n a.addEventListener('click', () => {\n details.open = true;\n });\n if (location.hash === hash) {\n details.open = true;\n }\n }\n}\n\n/**\n * Disable unavailable sections in navigation dropdown on mobile.\n */\nconst readmeOption = document.querySelector('.js-readmeOption');\nif (readmeOption && !readme) {\n readmeOption.setAttribute('disabled', 'true');\n}\nconst unitDirectories = document.querySelector('.js-unitDirectories');\nconst directoriesOption = document.querySelector('.js-directoriesOption');\nif (!unitDirectories && directoriesOption) {\n directoriesOption.setAttribute('disabled', 'true');\n}\ndocument.querySelectorAll('.js-buildContextSelect').forEach(el => {\n el.addEventListener('change', e => {\n window.location.search = `?GOOS=${(e.target as HTMLSelectElement).value}`;\n });\n});\n\n/**\n * Adds double click event listener to the header that will\n * scroll the page back to the top.\n */\nconst unitHeader = document.querySelector('.js-unitHeader');\nunitHeader?.addEventListener('dblclick', e => {\n const target = e.target as HTMLElement;\n if (\n target === unitHeader.firstElementChild &&\n unitHeader.classList.contains('UnitHeader--sticky')\n ) {\n window.getSelection()?.removeAllRanges();\n window.scrollTo({ top: 0 });\n }\n});\n\n/**\n * Calculates dynamic heights values for header elements to support\n * variable size sticky positioned elements in the header so that banners\n * and breadcumbs may overflow to multiple lines.\n */\nconst header = document.querySelector('.UnitHeader');\nconst breadcrumbs = header?.querySelector('.UnitHeader-breadcrumbs');\nconst content = header?.querySelector('.UnitHeader-content');\nconst calcSize = () => {\n document.documentElement.style.removeProperty('--full-header-height');\n document.documentElement.style.setProperty(\n '--full-header-height',\n `${(header?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n document.documentElement.style.setProperty('--banner-height', `0rem`);\n document.documentElement.style.setProperty(\n '--breadcrumbs-height',\n `${(breadcrumbs?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n document.documentElement.style.setProperty(\n '--content-height',\n `${(content?.getBoundingClientRect().height ?? 0) / 16}rem`\n );\n};\ncalcSize();\nwindow.addEventListener('resize', function () {\n calcSize();\n});\n\n/**\n * Observer for header that applies classnames to transition\n * header elements into their sticky position and back into the\n * full size position.\n */\nconst observer = new IntersectionObserver(\n ([e]) => {\n if (e.intersectionRatio < 1) {\n unitHeader?.classList.add('UnitHeader--sticky');\n unitHeader?.classList.remove('UnitHeader--full');\n } else {\n unitHeader?.classList.remove('UnitHeader--sticky');\n unitHeader?.classList.add('UnitHeader--full');\n calcSize();\n }\n },\n { threshold: 1.0, rootMargin: '40px' }\n);\n\nconst headerSentinel = document.querySelector('.js-headerSentinel');\nif (headerSentinel) {\n observer.observe(headerSentinel);\n}\n"], + "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAOA,2DACA,wBACA,2DAEA,SACG,iBAAmC,uBACnC,QACC,GACE,GAAI,GACF,EACA,SAAS,cAAiC,8BAQlD,SAAS,iBAAoC,uBAAuB,QAAQ,GAAM,CAChF,GAAI,GAA0B,KAMhC,KAAM,GAAS,SAAS,cAAc,cAChC,EAAgB,SAAS,cAAc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AAY,QAE7C,SAAS,iBAAiB,0BAA0B,QAAQ,GAAM,CAChE,EAAG,iBAAiB,SAAU,GAAK,CACjC,OAAO,SAAS,OAAS,SAAU,EAAE,OAA6B,YAQtE,KAAM,GAAa,SAAS,cAAc,kBAC1C,GAAY,iBAAiB,WAAY,GAAK,CAE5C,AACE,AAFa,EAAE,SAEJ,EAAW,mBACtB,EAAW,UAAU,SAAS,uBAE9B,QAAO,gBAAgB,kBACvB,OAAO,SAAS,CAAE,IAAK,OAS3B,KAAM,GAAS,SAAS,cAA2B,eAC7C,EAAc,GAAQ,cAA2B,2BACjD,EAAU,GAAQ,cAA2B,uBAC7C,EAAW,IAAM,CACrB,SAAS,gBAAgB,MAAM,eAAe,wBAC9C,SAAS,gBAAgB,MAAM,YAC7B,uBACA,GAAI,IAAQ,wBAAwB,QAAU,GAAK,SAErD,SAAS,gBAAgB,MAAM,YAAY,kBAAmB,QAC9D,SAAS,gBAAgB,MAAM,YAC7B,uBACA,GAAI,IAAa,wBAAwB,QAAU,GAAK,SAE1D,SAAS,gBAAgB,MAAM,YAC7B,mBACA,GAAI,IAAS,wBAAwB,QAAU,GAAK,UAGxD,IACA,OAAO,iBAAiB,SAAU,UAAY,CAC5C,MAQF,KAAM,GAAW,GAAI,sBACnB,CAAC,CAAC,KAAO,CACP,AAAI,EAAE,kBAAoB,EACxB,IAAY,UAAU,IAAI,sBAC1B,GAAY,UAAU,OAAO,qBAE7B,IAAY,UAAU,OAAO,sBAC7B,GAAY,UAAU,IAAI,oBAC1B,MAGJ,CAAE,UAAW,EAAK,WAAY,SAG1B,EAAiB,SAAS,cAAc,sBAC9C,AAAI,GACF,EAAS,QAAQ", "names": [] } diff --git a/content/static/js/unit.ts b/content/static/js/unit.ts index f54e01008..82d011578 100644 --- a/content/static/js/unit.ts +++ b/content/static/js/unit.ts @@ -75,6 +75,25 @@ if (readme && readmeContent && readmeOutline && readmeExpand.length && readmeCol }); } +/** + * Expand details items that are focused. This will expand + * deprecated symbols when they are navigated to from the index + * or a direct link. + */ +for (const a of document.querySelectorAll('.js-deprecatedTagLink')) { + const hash = new URL(a.href).hash; + const heading = document.querySelector(hash); + const details = heading?.parentElement?.parentElement as HTMLDetailsElement | null; + if (details) { + a.addEventListener('click', () => { + details.open = true; + }); + if (location.hash === hash) { + details.open = true; + } + } +} + /** * Disable unavailable sections in navigation dropdown on mobile. */ diff --git a/internal/godoc/dochtml/testdata/deprecated-off.golden b/internal/godoc/dochtml/testdata/deprecated-off.golden index edf69c4a3..270f1be6c 100644 --- a/internal/godoc/dochtml/testdata/deprecated-off.golden +++ b/internal/godoc/dochtml/testdata/deprecated-off.golden @@ -11,23 +11,33 @@ func BadF()
  • func GoodF()
  • -
  • type BadT
  • +
  • +type BadT
  • -
  • type GoodT
  • +
  • +type GoodT
  • Constants

    diff --git a/internal/godoc/dochtml/testdata/deprecated-on.golden b/internal/godoc/dochtml/testdata/deprecated-on.golden index 13db3e879..7071c9b58 100644 --- a/internal/godoc/dochtml/testdata/deprecated-on.golden +++ b/internal/godoc/dochtml/testdata/deprecated-on.golden @@ -8,26 +8,36 @@
  • Constants
  • Variables
  • -func BadF()deprecated
  • +func BadF()deprecated
  • func GoodF()
  • -
  • type BadTdeprecated
  • +
  • +type BadTdeprecated
  • -
  • type GoodT
  • +
  • +type GoodT
  • Constants

    @@ -59,23 +69,30 @@ Deprecated: use GoodC.

    Functions

    -
    +

    - -func BadF -deprecated + +func BadF +deprecated +

    +
    +
    + +This function has been deprecated. +
    func BadF()

    BadF is bad. Deprecated: use GoodF.

    +

    @@ -89,17 +106,23 @@ Deprecated: use GoodF.

    Types

    -
    +

    - -type BadT -deprecated + +type BadT +deprecated +

    +
    +
    + +This type has been deprecated. +
    type BadT int
    @@ -108,22 +131,29 @@ Deprecated: use GoodT. Don't use this.

    -
    +

    - -func NewBadTBad -deprecated + +func NewBadTBad +deprecated +

    +
    +
    + +This function has been deprecated. +
    func NewBadTBad() BadT

    Deprecated: use NewBadTGood.

    +

    @@ -135,22 +165,29 @@ func NewBadTBad BadT

    -
    +

    - -func (BadT) BadM -deprecated + +func (BadT) BadM +deprecated +

    +
    +
    + +This method has been deprecated. +
    func (BadT) BadM()

    Deprecated: use GoodM.

    +

    @@ -162,6 +199,7 @@ func (BadT) BadM BadT) GoodM()

    +

    @@ -173,23 +211,30 @@ func (BadT) BadM int

    -
    +

    - -func NewGoodTBad -deprecated + +func NewGoodTBad +deprecated +

    +
    +
    + +This function has been deprecated. +
    func NewGoodTBad() GoodT

    NewGoodTBad is bad. Deprecated: use NewGoodTGood.

    +

    @@ -201,23 +246,30 @@ Deprecated: use NewGoodTGood.
    func NewGoodTGood() GoodT

    -
    +

    - -func (GoodT) BadM -deprecated + +func (GoodT) BadM +deprecated +

    +
    +
    + +This method has been deprecated. +
    func (GoodT) BadM()

    BadM is bad. Deprecated: use GoodM.

    +

    diff --git a/internal/godoc/dochtml/testdata/everydecl.golden b/internal/godoc/dochtml/testdata/everydecl.golden index e70766daa..3bf95bdf0 100644 --- a/internal/godoc/dochtml/testdata/everydecl.golden +++ b/internal/godoc/dochtml/testdata/everydecl.golden @@ -11,18 +11,27 @@ attributes.
  • Variables
  • func F()
  • -
  • type A
  • -
  • type B
  • -
  • type I1
  • -
  • type I2
  • -
  • type S1
  • -
  • type S2
  • -
  • type T
  • +
  • +type A
  • +
  • +type B
  • +
  • +type I1
  • +
  • +type I2
  • +
  • +type S1
  • +
  • +type S2
  • +
  • +type T
  • Bugs
  • Constants