Skip to content

Commit 1b55285

Browse files
committed
Remove --gaId option
Closes #2600
1 parent 2dde2e9 commit 1b55285

File tree

11 files changed

+20
-70
lines changed

11 files changed

+20
-70
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Removed `--includes` option, use the `@document` tag instead.
1717
- Removed `--stripYamlFrontmatter` option, TypeDoc will always do this now.
1818
- Renamed the `--htmlLang` option to `--lang`.
19+
- Removed the `--gaId` option for Google Analytics integration and corresponding `analytics` theme member, #2600.
1920
- All function-likes may now have comments directly attached to them. This is a change from previous versions of TypeDoc where functions comments
2021
were always moved down to the signature level. This mostly worked, but caused problems with type aliases, so was partially changed in 0.25.13.
2122
This change was extended to apply not only to type aliases, but also other function-likes declared with variables and callable properties.

internal-docs/custom-themes.md

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,28 @@ export function load(app: Application) {
1717
}
1818
```
1919

20-
This isn't very interesting since it exactly duplicates the default theme. Most themes need to adjust the templates
21-
in some way. This can be done by providing them class which returns a different context class. Say we wanted to replace
22-
TypeDoc's default analytics helper with one that uses [Open Web Analytics](https://www.openwebanalytics.com/) instead of
23-
Google Analytics. This could be done with the following theme:
20+
This isn't very interesting since it exactly duplicates the default theme.
21+
Most themes need to adjust the templates in some way. This can be done by
22+
providing them class which returns a different context class. Say we wanted
23+
to replace TypeDoc's default footer with one that mentioned your copyright.
24+
This could be done with the following theme.
25+
26+
In this case, it would probably be better to add this content using a render
27+
hook for `footer.begin` or `footer.end`, but it can be done in this way as well.
2428

2529
```tsx
2630
import { Application, DefaultTheme, PageEvent, JSX, Reflection } from "typedoc";
2731

28-
const script = `
29-
(function() {
30-
var _owa = document.createElement('script'); _owa.type = 'text/javascript';
31-
_owa.async = true; _owa.src = '${site}' + '/modules/base/js/owa.tracker-combined-min.js';
32-
var _owa_s = document.getElementsByTagName('script')[0]; _owa_s.parentNode.insertBefore(_owa,
33-
_owa_s);
34-
}());
35-
`.trim();
36-
3732
class MyThemeContext extends DefaultThemeRenderContext {
38-
// Important: If you use `this`, this function MUST be bound! Template functions are free
39-
// to destructure the context object to only grab what they care about.
40-
override analytics = () => {
41-
// Reusing existing option rather than declaring our own for brevity
42-
if (!this.options.isSet("gaId")) return;
43-
44-
const site = this.options.getValue("gaId");
45-
33+
// Important: If you use `this`, this function MUST be bound! Template functions
34+
// are free to destructure the context object to only grab what they care about.
35+
override footer = (context) => {
4636
return (
47-
<script>
48-
<JSX.Raw html={script} />
49-
</script>
37+
<footer>
38+
{context.hook("footer.begin", context)}
39+
Copyright 2024
40+
{context.hook("footer.end", context)}
41+
</footer>
5042
);
5143
};
5244
}
@@ -62,7 +54,7 @@ export function load(app: Application) {
6254
}
6355
```
6456

65-
## Hooks (v0.22.8+)
57+
## Hooks
6658

6759
When rendering themes, TypeDoc's default theme will call several functions to allow plugins to inject HTML
6860
into a page without completely overwriting a theme. Hooks live on the parent `Renderer` and may be called

src/lib/internationalization/locales/jp.cts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ export = buildIncompleteTranslation({
283283
"出力フォルダ内の sitemap.xml と正規リンクを生成する際に使用するベース URL を指定します。指定しない場合は、サイトマップは生成されません。",
284284
help_useHostedBaseUrlForAbsoluteLinks:
285285
"設定されている場合、TypeDocはhostedBaseUrlオプションを使用してサイト上のページへの絶対リンクを生成します。",
286-
help_gaID:
287-
"Google AnalyticsのトラッキングIDを設定し、トラッキングコードを有効にする",
288286
help_hideGenerator:
289287
"ページの最後にある TypeDoc リンクを印刷しないでください",
290288
help_customFooterHtml: "TypeDoc リンクの後のカスタム フッター",

src/lib/internationalization/locales/zh.cts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ export = buildIncompleteTranslation({
238238
"指定用于在我们的输出文件夹和规范链接中生成 sitemap.xml 的基本 URL。如果未指定,则不会生成站点地图",
239239
help_useHostedBaseUrlForAbsoluteLinks:
240240
"如果设置,TypeDoc 将使用 hostingBaseUrl 选项生成到您网站页面的绝对链接",
241-
help_gaID: "设置 Google Analytics 跟踪 ID 并激活跟踪代码",
242241
help_hideGenerator: "不要打印页面末尾的 TypeDoc 链接",
243242
help_customFooterHtml: "TypeDoc 链接后的自定义页脚",
244243
help_customFooterHtmlDisableWrapper:

src/lib/internationalization/translatable.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ export const translatable = {
274274
"Specify a base URL to be used in generating a sitemap.xml in our output folder and canonical links. If not specified, no sitemap will be generated",
275275
help_useHostedBaseUrlForAbsoluteLinks:
276276
"If set, TypeDoc will produce absolute links to pages on your site using the hostedBaseUrl option",
277-
help_gaID:
278-
"Set the Google Analytics tracking ID and activate tracking code",
279277
help_hideGenerator: "Do not print the TypeDoc link at the end of the page",
280278
help_customFooterHtml: "Custom footer after the TypeDoc link",
281279
help_customFooterHtmlDisableWrapper:

src/lib/output/themes/default/DefaultThemeRenderContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { type NeverIfInternal, type Options } from "../../../utils";
1313
import type { DefaultTheme } from "./DefaultTheme";
1414
import { defaultLayout } from "./layouts/default";
1515
import { index } from "./partials";
16-
import { analytics } from "./partials/analytics";
1716
import { breadcrumb } from "./partials/breadcrumb";
1817
import {
1918
commentSummary,
@@ -128,7 +127,6 @@ export class DefaultThemeRenderContext {
128127
*/
129128
reflectionPreview = bind(reflectionPreview, this);
130129

131-
analytics = bind(analytics, this);
132130
breadcrumb = bind(breadcrumb, this);
133131
commentSummary = bind(commentSummary, this);
134132
commentTags = bind(commentTags, this);

src/lib/output/themes/default/layouts/default.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export const defaultLayout = (
7373

7474
<div class="overlay"></div>
7575

76-
{context.analytics()}
7776
{context.hook("body.end", context)}
7877
</body>
7978
</html>

src/lib/output/themes/default/partials/analytics.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/lib/output/themes/default/partials/comment.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
22
import { JSX, Raw } from "../../../../utils";
33
import { type Reflection, ReflectionKind } from "../../../../models";
44
import { anchorIcon } from "./anchor-icon";
5+
import { join } from "../../lib";
56

67
// Note: Comment modifiers are handled in `renderFlags`
78

@@ -65,13 +66,5 @@ export function reflectionFlags(context: DefaultThemeRenderContext, props: Refle
6566
}
6667
}
6768

68-
return (
69-
<>
70-
{allFlags.map((item) => (
71-
<>
72-
<code class={"tsd-tag ts-flag" + item}>{item}</code>{" "}
73-
</>
74-
))}
75-
</>
76-
);
69+
return join(" ", allFlags, (item) => <code class="tsd-tag">{item}</code>);
7770
}

src/lib/utils/options/declaration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ export interface TypeDocOptionMap {
165165
hostedBaseUrl: string;
166166
useHostedBaseUrlForAbsoluteLinks: boolean;
167167
cacheBust: boolean;
168-
gaID: string;
169168
hideGenerator: boolean;
170169
customFooterHtml: string;
171170
customFooterHtmlDisableWrapper: boolean;

0 commit comments

Comments
 (0)