Skip to content

Commit

Permalink
Merge pull request #10 from issp-center-dev/changedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi authored Mar 7, 2021
2 parents 17d8107 + de86628 commit 16c8ecd
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 78 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- master
- develop
- '!gh-pages'
- changedocs
tags: '*'

jobs:
Expand All @@ -19,6 +20,7 @@ jobs:
uses: actions/checkout@v2
with:
path: main
fetch-depth: 0

- name: Checkout gh-pages
uses: actions/checkout@v2
Expand All @@ -38,6 +40,8 @@ jobs:
pip install tox tox-gh-actions
- name: Build docs with tox
env:
TARGET_NAME: ${{ env.GITHUB_REF_SLUG }}
run: |
cd main
tox -e docs
Expand Down
47 changes: 47 additions & 0 deletions docs/sphinx/manual/_templates/versions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{# The original version of this file is a part of sphinx_rtd_theme v0.5.0, which is distributed under the MIT license #}
{# https://github.com/readthedocs/sphinx_rtd_theme #}

{# Add rst-badge after rst-versions for small badge style. #}
{% if ENABLE_VERSIONING == "true" %}
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Read the Docs</span>
v: {{ current_version }}
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>{{ _('Languages') }}</dt>
{% for lang in languages %}
{% set root_dir = pathto("../..", 1)%}
<dd>
{% if lang == current_lang %}<strong>{% endif %}
<a href="{{root_dir}}/{{current_version}}/{{lang}}/{{pathto(pagename, 0, ".")}}">{{ lang }}</a>
{% if lang == current_lang %}</strong>{% endif %}
</dd>
{% endfor %}

<dt>{{ _('Branches') }}</dt>
{% for name in branches %}
{% set root_dir = pathto("../..", 1)%}
<dd>
{% if name == current_version %}<strong>{% endif %}
<a href="{{root_dir}}/{{name}}/{{current_lang}}/{{pathto(pagename, 0, ".")}}">{{ name }}</a>
{% if name == current_version %}</strong>{% endif %}
</dd>
{% endfor %}

<dt>{{ _('Tags') }}</dt>
{% for name in tags %}
{% set root_dir = pathto("../..", 1)%}
<dd>
{% if name == current_version %}<strong>{% endif %}
<a href="{{root_dir}}/{{name}}/{{current_lang}}/{{pathto(pagename, 0, ".")}}">{{ name }}</a>
{% if name == current_version %}</strong>{% endif %}
</dd>
{% endfor %}

</dl>
</div>
</div>
{% endif %} {# endif ENABLE_VERSIONING #}
157 changes: 93 additions & 64 deletions docs/sphinx/manual/en/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

import sys
import os
sys.path.insert(0, os.path.abspath('../../../../../physbo'))

sys.path.insert(0, os.path.abspath("../../../../../physbo"))

# -- Project information -----------------------------------------------------

Expand All @@ -31,29 +32,36 @@
author = "PHYSBO developers"

# The short X.Y version.
version = '1.0-beta'
version = "1.0-beta"
# The full version, including alpha/beta/rc tags.
release = '1.0.0-beta'
release = "1.0.0-beta"

# for jupyter-notebook

from recommonmark.parser import CommonMarkParser

source_parsers = {
'.md': CommonMarkParser,
".md": CommonMarkParser,
}

from recommonmark.transform import AutoStructify

github_doc_root = 'https://github.com/rtfd/recommonmark/tree/master/doc/'
github_doc_root = "https://github.com/rtfd/recommonmark/tree/master/doc/"


def setup(app):
app.add_config_value('recommonmark_config', {
'url_resolver': lambda url: github_doc_root + url,
'auto_toc_tree_section': 'Contents',
}, True)
app.add_config_value(
"recommonmark_config",
{
"url_resolver": lambda url: github_doc_root + url,
"auto_toc_tree_section": "Contents",
},
True,
)
app.add_transform(AutoStructify)

pygments_style = 'sphinx'

pygments_style = "sphinx"
nbsphinx_execute = "never"

# -- General configuration ------------------------------------------------
Expand Down Expand Up @@ -81,47 +89,33 @@ def setup(app):
numfig = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["../../_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', '**.ipynb_checkpoints']
for t in ('tag-latex', 'tag-latexpdf', 'tag-latexpdfja'):
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
for t in ("tag-latex", "tag-latexpdf", "tag-latexpdfja"):
if t in tags:
exclude_patterns.append('api')
exclude_patterns.append("api")

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# The master toctree document.
master_doc = 'index'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'1.0.0'
# The full version, including alpha/beta/rc tags.
release = u'1.0.0'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []
language = "en"

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -132,47 +126,42 @@ def setup(app):
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"
html_log = "logo.png"
html_theme_options = {
'logo_only': True
}
html_theme_options = {"logo_only": True}


# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'font_family': 'Helvetica',
'sidebar_search_button': 'pink_1'
}
html_theme_options = {"font_family": "Helvetica", "sidebar_search_button": "pink_1"}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['../../_static']
html_static_path = ["../../_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html',
'searchbox.html',
'donate.html',
]
}
# html_sidebars = {
# "**": [
# "about.html",
# "navigation.html",
# "relations.html",
# "searchbox.html",
# "donate.html",
# ]
# }


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'PHYSBOdoc'
htmlhelp_basename = "PHYSBOdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -181,15 +170,12 @@ def setup(app):
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -199,21 +185,24 @@ def setup(app):
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index','PHYSBO_en.tex', u'PHYSBO Documentation',
u'PHYSBO\'s team', 'manual', 'True'),
(
"index",
"PHYSBO_en.tex",
u"PHYSBO Documentation",
u"PHYSBO's team",
"manual",
"True",
),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'PHYSBO', u'PHYSBO Documentation',
[author], 1)
]
man_pages = [(master_doc, "PHYSBO", u"PHYSBO Documentation", [author], 1)]

#latex_docclass = {'manual': 'jsbook'}
# latex_docclass = {'manual': 'jsbook'}
latex_logo = "../../_static/logo.png"

# -- Options for Texinfo output -------------------------------------------
Expand All @@ -222,7 +211,47 @@ def setup(app):
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PHYSBO', u'PHYSBO Documentation',
author, 'PHYSBO', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"PHYSBO",
u"PHYSBO Documentation",
author,
"PHYSBO",
"One line description of project.",
"Miscellaneous",
),
]

# -- configuring _template/version.html -------------------------------------

html_context = {}

html_context["ENABLE_VERSIONING"] = os.environ.get("CI", "false")

html_context["languages"] = [("en"), ("ja")]
html_context["current_lang"] = language

current_version = os.environ.get("TARGET_NAME", "")
if not current_version:
current_version = release
html_context["current_version"] = current_version

html_context["branches"] = ["develop", "master"]
html_context["tags"] = []
exclude_tags = ["v0.1.0", "v0.2.0", "v0.3.0"]

try:
import git

repo = git.Repo(search_parent_directories=True)
tags = list(map(str, repo.tags))
tags.sort(reverse=True)
for tag in tags:
if tag not in exclude_tags:
html_context["tags"].append(tag)
except:
pass

if current_version not in html_context["branches"]:
if current_version not in html_context["tags"]:
html_context["branches"].append(current_version)
Loading

0 comments on commit 16c8ecd

Please sign in to comment.