Skip to content

Commit 7d3ae79

Browse files
authored
Change sphinx theme (#8)
* Moved tutorials * Updated conf and wrote docs in markdown * Updated gitignore * Updated instructions * Removed sidebar * Updated navbar color * Removed caption * Added sphinx_bootstrap_theme to deps
1 parent 78f5e47 commit 7d3ae79

11 files changed

Lines changed: 172 additions & 79 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ instance/
7171

7272
# Sphinx documentation
7373
docs/_build/
74+
docs/source/tutorials/
7475

7576
# PyBuilder
7677
.pybuilder/

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ template-python
3030

3131

3232
```
33-
# https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594
34-
sphinx-apidoc -o docs/ src/app/
35-
cd docs/
36-
make clean
3733
make html
3834
cd ../
3935
open docs/_build/html/index.html

docs/source/api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# API
2+
3+
Description of the API
4+
5+
```{toctree}
6+
:maxdepth: 1

docs/source/conf.py

Lines changed: 106 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import os
77
import shutil
8-
8+
# At the top.
9+
import sphinx_bootstrap_theme
910

1011
def copy_tutorials(app):
1112
src = os.path.abspath("../tutorials")
@@ -20,14 +21,16 @@ def copy_tutorials(app):
2021

2122
def setup(app):
2223
app.connect("builder-inited", copy_tutorials)
24+
# app.add_stylesheet("my-styles.css")
25+
app.add_css_file("custom.css")
2326

2427

2528
# -- Project information -----------------------------------------------------
2629
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
2730

2831
project = "python-template"
29-
copyright = "2025, Max Lindqvist"
30-
author = "Max Lindqvist"
32+
copyright = "2025, Max"
33+
author = "Max"
3134

3235
# -- General configuration ---------------------------------------------------
3336
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -36,14 +39,112 @@ def setup(app):
3639
"nbsphinx",
3740
"sphinx.ext.mathjax",
3841
"sphinx.ext.autodoc",
42+
"myst_parser", # enable Markdown support
3943
]
4044

41-
templates_path = ["_templates"]
4245
exclude_patterns = []
4346

47+
# Recognize both .rst and .md
48+
source_suffix = {
49+
".rst": "restructuredtext",
50+
".md": "markdown",
51+
}
4452

4553
# -- Options for HTML output -------------------------------------------------
4654
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
4755

48-
html_theme = "sphinx_rtd_theme"
56+
# html_theme = "furo"
57+
# conf.py
58+
# ...
59+
60+
# Activate the theme.
61+
html_theme = 'bootstrap'
62+
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
63+
64+
# (Optional) Logo. Should be small enough to fit the navbar (ideally 24x24).
65+
# Path should be relative to the ``_static`` files directory.
66+
# html_logo = "my_logo.png"
67+
68+
# Theme options are theme-specific and customize the look and feel of a
69+
# theme further.
70+
html_theme_options = {
71+
# Navigation bar title. (Default: ``project`` value)
72+
'navbar_title': "python-template",
73+
74+
# Tab name for entire site. (Default: "Site")
75+
76+
'navbar_site_name': "Site",
77+
78+
# A list of tuples containing pages or urls to link to.
79+
# Valid tuples should be in the following forms:
80+
# (name, page) # a link to a page
81+
# (name, "/aa/bb", 1) # a link to an arbitrary relative url
82+
# (name, "http://example.com", True) # arbitrary absolute url
83+
# Note the "1" or "True" value above as the third argument to indicate
84+
# an arbitrary url.
85+
'navbar_links': [
86+
("Quickstart", "quickstart"),
87+
("Tutorials", "tutorial"),
88+
("API", "api"),
89+
# ("Link", "http://example.com", True),
90+
],
91+
92+
# Render the next and previous page links in navbar. (Default: true)
93+
'navbar_sidebarrel': False,
94+
95+
# Render the current pages TOC in the navbar. (Default: true)
96+
'navbar_pagenav': False,
97+
98+
# Tab name for the current pages TOC. (Default: "Page")
99+
'navbar_pagenav_name': "Page",
100+
101+
# Global TOC depth for "site" navbar tab. (Default: 1)
102+
# Switching to -1 shows all levels.
103+
'globaltoc_depth': 2,
104+
105+
# Include hidden TOCs in Site navbar?
106+
#
107+
# Note: If this is "false", you cannot have mixed ``:hidden:`` and
108+
# non-hidden ``toctree`` directives in the same page, or else the build
109+
# will break.
110+
#
111+
# Values: "true" (default) or "false"
112+
'globaltoc_includehidden': "true",
113+
114+
# HTML navbar class (Default: "navbar") to attach to <div> element.
115+
# For black navbar, do "navbar navbar-inverse"
116+
'navbar_class': "navbar inverse",
117+
118+
# Fix navigation bar to top of page?
119+
# Values: "true" (default) or "false"
120+
'navbar_fixed_top': "true",
121+
122+
# Location of link to source.
123+
# Options are "nav" (default), "footer" or anything else to exclude.
124+
'source_link_position': "footer",
125+
126+
# Bootswatch (http://bootswatch.com/) theme.
127+
#
128+
# Options are nothing (default) or the name of a valid theme
129+
# such as "cosmo" or "sandstone".
130+
#
131+
# The set of valid themes depend on the version of Bootstrap
132+
# that's used (the next config option).
133+
#
134+
# Currently, the supported themes are:
135+
# - Bootstrap 2: https://bootswatch.com/2
136+
# - Bootstrap 3: https://bootswatch.com/3
137+
'bootswatch_theme': "flatly",
138+
139+
# Choose Bootstrap version.
140+
# Values: "3" (default) or "2" (in quotes)
141+
'bootstrap_version': "3",
142+
}
143+
49144
html_static_path = ["_static"]
145+
templates_path = ['_templates']
146+
147+
148+
html_sidebars = {
149+
'**': []
150+
}

docs/source/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Welcome
2+
3+
Write the documentation of your python package here
4+
5+
```{toctree}
6+
:maxdepth: 2
7+
:caption: Contents
8+
9+
quickstart.md
10+
tutorials.md
11+
api.md

docs/source/index.rst

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

docs/source/quickstart.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Quickstart
2+
3+
Clone the repo
4+
5+
```
6+
git clone ...
7+
```
8+
9+
Create and activate python environment
10+
11+
```
12+
python -m venv env
13+
source env/bin/activate
14+
pip install --upgrade pip
15+
```
16+
17+
Install the code and requirements with pip
18+
19+
```
20+
pip install -e .
21+
```
22+
23+
Run the code with
24+
25+
```
26+
template-python
27+
```
28+
29+
# Build docs
30+
31+
```
32+
make html
33+
cd ../
34+
open docs/_build/html/index.html
35+
```
36+
37+
```{toctree}
38+
:maxdepth: 1

docs/source/tutorials.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Tutorials
2+
3+
Here are a few tutorials to help you get started.
4+
5+
```{toctree}
6+
:maxdepth: 1
7+
:glob:
8+
9+
tutorials/*

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ optional-dependencies.docs = [
4343
"pyproject-fmt",
4444
"sphinx",
4545
"sphinx-rtd-theme",
46+
"sphinx_bootstrap_theme",
4647
]
4748
optional-dependencies.test = [ "coverage", "pytest" ]
4849
urls."Source" = "https://github.com/max-models/template-python"

0 commit comments

Comments
 (0)