Skip to content

Commit 0bece13

Browse files
committed
feat: ドキュメントのバージョン表示を改善し、テーマを変更
1 parent 8fbb175 commit 0bece13

File tree

3 files changed

+87
-18
lines changed

3 files changed

+87
-18
lines changed

docs/source/_templates/versions.html

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,96 @@
1+
<style>
2+
.rst-versions {
3+
border: 1px solid #ddd;
4+
padding: 10px;
5+
border-radius: 5px;
6+
margin-bottom: 20px;
7+
}
8+
9+
.rst-current-version {
10+
font-weight: bold;
11+
cursor: pointer;
12+
}
13+
14+
.rst-other-versions {
15+
display: none; /* 初期状態では非表示 */
16+
}
17+
18+
.rst-other-versions dl {
19+
margin: 0;
20+
padding: 0;
21+
}
22+
23+
.rst-other-versions dt {
24+
font-weight: bold;
25+
margin-top: 10px;
26+
}
27+
28+
.rst-other-versions dd {
29+
margin: 0;
30+
padding: 0 0 0 10px;
31+
display: flex;
32+
flex-wrap: wrap;
33+
}
34+
35+
.rst-other-versions a {
36+
text-decoration: none;
37+
color: #27ae60;
38+
margin-right: 10px;
39+
}
40+
41+
.rst-other-versions a:hover {
42+
text-decoration: underline;
43+
}
44+
</style>
45+
146
<div
247
class="rst-versions"
348
data-toggle="rst-versions"
449
role="note"
550
aria-label="versions"
651
>
7-
<span class="rst-current-version" data-toggle="rst-current-version">
52+
<span
53+
class="rst-current-version"
54+
data-toggle="rst-current-version"
55+
onclick="toggleVersions()"
56+
>
857
Language: {{ current_language }}
958
<span class="fa fa-caret-down"></span>
1059
</span>
1160
<div class="rst-other-versions">
1261
{% if languages|length >= 1 %}
1362
<dl>
1463
<dt>{{ _('Languages') }}</dt>
15-
{% for the_language, url in languages %}
16-
<dd><a href="{{ url }}/index.html">{{ the_language }}</a></dd>
17-
{% endfor %}
64+
<dd>
65+
{% for the_language, url in languages %}
66+
<a href="{{ url }}/index.html">{{ the_language }}</a>
67+
{% endfor %}
68+
</dd>
1869
</dl>
1970
{% endif %}
2071
<!-- {% if versions|length >= 1 %}
21-
<dl>
22-
<dt>{{ _('Versions') }}</dt>
23-
{% for the_version, url in versions %}
24-
<dd><a href="{{ url }}/index.html">{{ the_version }}</a></dd>
25-
{% endfor %}
26-
</dl>
27-
{% endif %}
28-
<br>
29-
</dl> -->
72+
<dl>
73+
<dt>{{ _('Versions') }}</dt>
74+
{% for the_version, url in versions %}
75+
<dd><a href="{{ url }}/index.html">{{ the_version }}</a></dd>
76+
{% endfor %}
77+
</dl>
78+
{% endif %}
79+
<br>
80+
</dl> -->
3081
</div>
3182
</div>
83+
84+
<script>
85+
function toggleVersions() {
86+
var versionsDiv = document.querySelector(".rst-other-versions");
87+
if (
88+
versionsDiv.style.display === "none" ||
89+
versionsDiv.style.display === ""
90+
) {
91+
versionsDiv.style.display = "block";
92+
} else {
93+
versionsDiv.style.display = "none";
94+
}
95+
}
96+
</script>

docs/source/conf.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
# -- Options for HTML output -------------------------------------------------
3838
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3939

40-
html_theme = "sphinx_rtd_theme"
40+
html_theme = "sphinx_book_theme"
41+
42+
html_sidebars = {
43+
"**": ["navbar-logo.html", "versions.html", "search-button-field.html", "sbt-sidebar-nav.html"]
44+
}
45+
4146
html_static_path = ["_static"]
4247

4348
locale_dirs = ["locale"]
@@ -53,7 +58,7 @@
5358
current_language = os.environ.get("current_language")
5459
current_version = os.environ.get("current_version")
5560

56-
# we set the html_context wit current language and version
61+
# we set the html_context wit current language and version
5762
# and empty languages and versions for now
5863
html_context = {
5964
'current_language' : current_language,
@@ -63,8 +68,8 @@
6368
}
6469

6570

66-
# and we append all versions and langauges accordingly
67-
# we treat t he main branch as latest
71+
# and we append all versions and langauges accordingly
72+
# we treat t he main branch as latest
6873
if (current_version == 'latest'):
6974
html_context['languages'].append(['en', pages_root])
7075
html_context['languages'].append(['ja', pages_root+'/ja'])

docs/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ adf-core-pythonを始めるには、インストールに従い、このドキ
7171
:maxdepth: 1
7272
:caption: APIドキュメント
7373

74-
genindex
7574
modindex
7675
search
7776

0 commit comments

Comments
 (0)