Skip to content

Commit

Permalink
init readthedoc theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Yikai-Liao committed Dec 24, 2023
1 parent ff6bfdb commit 628a514
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ sphinx:
# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
python:
install:
- requirements: docs/requirements.txt
46 changes: 6 additions & 40 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,6 @@

logger = logging.getLogger("symsuic")


def get_git_branch():
"""Get the git branch this repository is currently on"""
path_to_here = os.path.abspath(os.path.dirname(__file__))

# Invoke git to get the current branch which we use to get the theme
try:
p = subprocess.Popen(
["git", "branch"], stdout=subprocess.PIPE, cwd=path_to_here
)

# This will contain something like "* (HEAD detached at origin/MYBRANCH)"
# or something like "* MYBRANCH"
branch_output = p.communicate()[0]

# This is if git is in a normal branch state
match = re.search(r"\* (?P<branch_name>[^\(\)\n ]+)", branch_output)
if match:
return match.groupdict()["branch_name"]

# git is in a detached HEAD state
match = re.search(
r"\(HEAD detached at origin/(?P<branch_name>[^\)]+)\)", branch_output
)
if match:
return match.groupdict()["branch_name"]
except Exception:
logger.exception("Could not get the branch")

# Couldn't figure out the branch probably due to an error
return None


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

project = "symusic"
Expand Down Expand Up @@ -124,7 +91,7 @@ def get_git_branch():
"pyramid": "pyramid",
"bizstyle": "bizstyle",
}
current_branch = get_git_branch()
# current_branch = get_git_branch()

# if current_branch:
# sphinx_html_theme = branch_to_theme_mapping.get(current_branch, default_html_theme)
Expand All @@ -133,12 +100,11 @@ def get_git_branch():
# sphinx_html_theme = default_html_theme
# print(u'Error getting current branch - using default theme')

sphinx_html_theme = default_html_theme
extensions = [
'sphinx_rtd_theme',
]

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = sphinx_html_theme
html_theme = "sphinx_rtd_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
Expand All @@ -149,7 +115,7 @@ def get_git_branch():
# 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.
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx_rtd_theme

0 comments on commit 628a514

Please sign in to comment.