You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2021/05/09 11:54:04 UTC
[incubator-annotator-website] 04/06: Remix TypeDoc into our
templates
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-annotator-website.git
commit 69735230fcef1470a3b288b197a032d5ddb5a102
Author: Gerben <ge...@treora.com>
AuthorDate: Sat May 8 23:48:30 2021 +0200
Remix TypeDoc into our templates
Copying some pieces from: https://github.com/TypeStrong/typedoc-default-themes
---
src/_layouts/default.hbs | 7 ++++-
typedoc_theme/layouts/default.hbs | 38 ++++++++++++++++++++++++
typedoc_theme/partials/page_footer.hbs | 1 +
typedoc_theme/partials/page_header.hbs | 1 +
typedoc_theme/partials/typedoc_breadcrumbs.hbs | 12 ++++++++
typedoc_theme/partials/typedoc_h1_title.hbs | 21 +++++++++++++
typedoc_theme/partials/typedoc_main_content.hbs | 28 +++++++++++++++++
typedoc_theme/partials/typedoc_search_widget.hbs | 18 +++++++++++
typedoc_theme/partials/website_default.hbs | 1 +
9 files changed, 126 insertions(+), 1 deletion(-)
diff --git a/src/_layouts/default.hbs b/src/_layouts/default.hbs
index c139d2e..56c2f1b 100644
--- a/src/_layouts/default.hbs
+++ b/src/_layouts/default.hbs
@@ -28,7 +28,12 @@
<body>
{{> page_header}}
<div class="ui basic segment container">
- {{{content}}}
+ {{!-- This template is used both in our TypeDoc theme, and in 11ty --}}
+ {{!-- For TypeDoc, we get the content as a handlebars partial block --}}
+ {{#> @partial-block}}
+ {{!-- For 11ty, we get the content as a variable --}}
+ {{{content}}}
+ {{/@partial-block}}
</div>
{{> page_footer}}
</body>
diff --git a/typedoc_theme/layouts/default.hbs b/typedoc_theme/layouts/default.hbs
new file mode 100644
index 0000000..fd92fa5
--- /dev/null
+++ b/typedoc_theme/layouts/default.hbs
@@ -0,0 +1,38 @@
+{{#> website_default isDocs=true}}
+ <link rel="stylesheet" href="{{relativeURL "assets/css/main.css"}}">
+ <script async src="{{relativeURL "assets/js/search.js"}}" id="search-script"></script>
+
+ <aside>
+ <style>
+ #tsd-search {
+ position: relative;
+ }
+ #tsd-search input {
+ border: 1px solid grey;
+ border-radius: 2px;
+ padding: 0.2em;
+ }
+ #tsd-search .results {
+ z-index: 1;
+ position: absolute;
+ }
+ </style>
+ {{> typedoc_search_widget}}
+ </aside>
+
+ <header style="margin: 2em 0;" id="typedoc-title">
+ <style>
+ #typedoc-title h1 {
+ margin-top: 0;
+ }
+ </style>
+ {{> typedoc_breadcrumbs}}
+ {{> typedoc_h1_title}}
+ </header>
+
+ <main>
+ {{> typedoc_main_content }}
+ </main>
+
+ <script src="{{relativeURL "assets/js/main.js"}}"></script>
+{{/website_default}}
diff --git a/typedoc_theme/partials/page_footer.hbs b/typedoc_theme/partials/page_footer.hbs
new file mode 120000
index 0000000..96d50ef
--- /dev/null
+++ b/typedoc_theme/partials/page_footer.hbs
@@ -0,0 +1 @@
+../../src/_includes/page_footer.hbs
\ No newline at end of file
diff --git a/typedoc_theme/partials/page_header.hbs b/typedoc_theme/partials/page_header.hbs
new file mode 120000
index 0000000..9992a34
--- /dev/null
+++ b/typedoc_theme/partials/page_header.hbs
@@ -0,0 +1 @@
+../../src/_includes/page_header.hbs
\ No newline at end of file
diff --git a/typedoc_theme/partials/typedoc_breadcrumbs.hbs b/typedoc_theme/partials/typedoc_breadcrumbs.hbs
new file mode 100644
index 0000000..990efca
--- /dev/null
+++ b/typedoc_theme/partials/typedoc_breadcrumbs.hbs
@@ -0,0 +1,12 @@
+{{!--
+Copyright (c) 2015 Sebastian Lenz.
+Copyright (c) 2016-2020 TypeDoc Contributors.
+Licensed under the Apache License 2.0.
+From: https://github.com/TypeStrong/typedoc-default-themes
+--}}
+
+{{#if model.parent}} {{! Don't show breadcrumbs on main project page, it is the root page. !}}
+ <ul class="tsd-breadcrumb">
+ {{#with model}}{{> breadcrumb}}{{/with}}
+ </ul>
+{{/if}}
diff --git a/typedoc_theme/partials/typedoc_h1_title.hbs b/typedoc_theme/partials/typedoc_h1_title.hbs
new file mode 100644
index 0000000..bfa8832
--- /dev/null
+++ b/typedoc_theme/partials/typedoc_h1_title.hbs
@@ -0,0 +1,21 @@
+{{!--
+Copyright (c) 2015 Sebastian Lenz.
+Copyright (c) 2016-2020 TypeDoc Contributors.
+Licensed under the Apache License 2.0.
+From: https://github.com/TypeStrong/typedoc-default-themes
+--}}
+
+<h1>{{#compact}}
+ {{#ifCond model.kindString "!==" "Project" }}
+ {{model.kindString}}
+ {{/ifCond}}
+ {{model.name}}
+ {{#if model.typeParameters}}
+ <
+ {{#each model.typeParameters}}
+ {{#if @index}}, {{/if}}
+ {{name}}
+ {{/each}}
+ >
+ {{/if}}
+{{/compact}}</h1>
diff --git a/typedoc_theme/partials/typedoc_main_content.hbs b/typedoc_theme/partials/typedoc_main_content.hbs
new file mode 100644
index 0000000..e1199d2
--- /dev/null
+++ b/typedoc_theme/partials/typedoc_main_content.hbs
@@ -0,0 +1,28 @@
+{{!--
+Copyright (c) 2015 Sebastian Lenz.
+Copyright (c) 2016-2020 TypeDoc Contributors.
+Licensed under the Apache License 2.0.
+From: https://github.com/TypeStrong/typedoc-default-themes
+--}}
+<div class="row">
+ <div class="col-8 col-content">
+ {{{contents}}}
+ </div>
+ <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
+ <nav class="tsd-navigation primary">
+ <ul>
+ {{#each navigation.children}}
+ {{> navigation}}
+ {{/each}}
+ </ul>
+ </nav>
+
+ <nav class="tsd-navigation secondary menu-sticky">
+ <ul class="before-current">
+ {{#each toc.children}}
+ {{> toc.root}}
+ {{/each}}
+ </ul>
+ </nav>
+ </div>
+</div>
diff --git a/typedoc_theme/partials/typedoc_search_widget.hbs b/typedoc_theme/partials/typedoc_search_widget.hbs
new file mode 100644
index 0000000..59cebaa
--- /dev/null
+++ b/typedoc_theme/partials/typedoc_search_widget.hbs
@@ -0,0 +1,18 @@
+{{!--
+Copyright (c) 2015 Sebastian Lenz.
+Copyright (c) 2016-2020 TypeDoc Contributors.
+Licensed under the Apache License 2.0.
+From: https://github.com/TypeStrong/typedoc-default-themes
+--}}
+
+<div id="tsd-search" data-index="{{relativeURL "assets/js/search.json"}}" data-base="{{relativeURL "./"}}">
+ <div>
+ <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
+ <input id="tsd-search-field" type="text" />
+ </div>
+
+ <ul class="results">
+ <li class="state loading">Preparing search index...</li>
+ <li class="state failure">The search index is not available</li>
+ </ul>
+</div>
diff --git a/typedoc_theme/partials/website_default.hbs b/typedoc_theme/partials/website_default.hbs
new file mode 120000
index 0000000..4c5a7fc
--- /dev/null
+++ b/typedoc_theme/partials/website_default.hbs
@@ -0,0 +1 @@
+../../src/_layouts/default.hbs
\ No newline at end of file