Skip to content

Commit

Permalink
Change theme to Sphinx Material Design
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
  • Loading branch information
rw1nkler authored and mithro committed Sep 28, 2019
1 parent 0690493 commit de5eec3
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 210 deletions.
1 change: 1 addition & 0 deletions docs/.gitignore
@@ -1 +1,2 @@
venv
_build
30 changes: 22 additions & 8 deletions docs/Makefile
@@ -1,13 +1,15 @@
# Minimal makefile for Sphinx documentation
#

MAKEDIR := $(dir $(lastword $(MAKEFILE_LIST)))

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXAUTOBUILD = sphinx-autobuild
SPHINXPROJ = ProjectX-Ray
SOURCEDIR = .
BUILDDIR = _build
SPHINXOPTS =
SPHINXBUILD = [ -e venv/bin/activate ] && source venv/bin/activate; sphinx-build
SPHINXAUTOBUILD = [ -e venv/bin/activate ] && source venv/bin/activate; sphinx-autobuild
SPHINXPROJ = ProjectTrellis
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -16,9 +18,21 @@ help:
livehtml:
@$(SPHINXAUTOBUILD) -b html --ignore \*.swp --ignore \*~ $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html"

.PHONY: help livereload Makefile
.PHONY: help livehtml Makefile

venv:
rm -rf venv
virtualenv --python=python3 venv
source venv/bin/activate; pip install -r requirements.txt

.PHONY: venv

links:
@true

.PHONY: links

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
%: Makefile links
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Empty file added docs/_static/.keepme
Empty file.
118 changes: 96 additions & 22 deletions docs/conf.py
Expand Up @@ -24,7 +24,7 @@
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
from markdown_code_symlinks import MarkdownCodeSymlinks
from markdown_code_symlinks import LinkParser, MarkdownSymlinksDomain

# -- General configuration ------------------------------------------------

Expand All @@ -36,8 +36,13 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.imgmath', 'sphinx.ext.autodoc', 'sphinx.ext.doctest',
'sphinx.ext.autosummary', 'sphinx.ext.napoleon', 'sphinx.ext.todo'
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.imgmath',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
'sphinx_markdown_tables',
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -47,7 +52,7 @@
# You can specify multiple suffix as a list of string:
source_suffix = ['.rst', '.md']
source_parsers = {
'.md': 'recommonmark.parser.CommonMarkParser',
'.md': 'markdown_code_symlinks.LinkParser',
}

# The master toctree document.
Expand All @@ -58,6 +63,24 @@
copyright = u'2018, SymbiFlow Team'
author = u'SymbiFlow Team'

# Enable github links when not on readthedocs
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd:
html_context = {
"display_github": True, # Integrate GitHub
"github_user": "symbiflow", # Username
"github_repo": "prjtrellis", # Repo name
"github_version": "master", # Version
"conf_py_path": "/doc/",
}
else:
docs_dir = os.path.abspath(os.path.dirname(__file__))
print("Docs dir is:", docs_dir)
import subprocess
subprocess.call('git fetch origin --unshallow', cwd=docs_dir, shell=True)
subprocess.check_call('git fetch origin --tags', cwd=docs_dir, shell=True)
subprocess.check_call('make links', cwd=docs_dir, shell=True)

# 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.
Expand All @@ -77,10 +100,10 @@
# 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 = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ['_build', 'venv', 'Thumbs.db', '.DS_Store']

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

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
Expand All @@ -90,24 +113,67 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = 'sphinx_materialdesign_theme'

# 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 = {}

# Enable github links when not on readthedocs
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd:
html_context = {
"display_github": True, # Integrate GitHub
"github_user": "symbiflow", # Username
"github_repo": "prjtrellis", # Repo name
"github_version": "master", # Version
"conf_py_path": "/doc/",
}
html_theme_options = {
# Specify a list of menu in Header.
# Tuples forms:
# ('Name', 'external url or path of pages in the document', boolean, 'icon name')
#
# Third argument:
# True indicates an external link.
# False indicates path of pages in the document.
#
# Fourth argument:
# Specify the icon name.
# For details see link.
# https://material.io/icons/
'header_links': [
('Home', 'index', False, 'home'),
("GitHub", "https://github.com/SymbiFlow/prjtrellis", True, 'link')
],

# Customize css colors.
# For details see link.
# https://getmdl.io/customize/index.html
#
# Values: amber, blue, brown, cyan deep_orange, deep_purple, green, grey, indigo, light_blue,
# light_green, lime, orange, pink, purple, red, teal, yellow(Default: indigo)
'primary_color':
'deep_purple',
# Values: Same as primary_color. (Default: pink)
'accent_color':
'purple',

# Customize layout.
# For details see link.
# https://getmdl.io/components/index.html#layout-section
'fixed_drawer':
True,
'fixed_header':
True,
'header_waterfall':
True,
'header_scroll':
False,

# Render title in header.
# Values: True, False (Default: False)
'show_header_title':
False,
# Render title in drawer.
# Values: True, False (Default: True)
'show_drawer_title':
True,
# Render footer.
# Values: True, False (Default: True)
'show_footer':
True
}

# 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,
Expand Down Expand Up @@ -184,9 +250,17 @@


def setup(app):
MarkdownCodeSymlinks.find_links()
github_code_repo = 'https://github.com/SymbiFlow/prjtrellis/'
github_code_branch = 'blob/master/'

docs_root_dir = os.path.realpath(os.path.dirname(__file__))
code_root_dir = os.path.realpath(os.path.join(docs_root_dir, ".."))

MarkdownSymlinksDomain.init_domain(
github_code_repo, github_code_branch, docs_root_dir, code_root_dir)
MarkdownSymlinksDomain.find_links()
app.add_domain(MarkdownSymlinksDomain)
app.add_config_value(
'recommonmark_config', {
'github_code_repo': 'https://github.com/SymbiFlow/prjtrellis',
'github_code_repo': github_code_repo,
}, True)
app.add_transform(MarkdownCodeSymlinks)

0 comments on commit de5eec3

Please sign in to comment.