Skip to content

Commit

Permalink
Merge pull request #54 from ru-fu/split-config
Browse files Browse the repository at this point in the history
split the configuration file into common and custom
  • Loading branch information
Peter Matulis authored Jul 7, 2023
2 parents 226d01d + 86fae8e commit 5afe29d
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 145 deletions.
213 changes: 98 additions & 115 deletions conf.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,19 @@
import datetime
import sys

sys.path.append('./')
from custom_conf import *

# Configuration file for the Sphinx documentation builder.
# You should not do any modifications to this file. Put your custom
# configuration into the custom_conf.py file.
# If you need to change this file, contribute the changes upstream.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

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

project = 'Documentation starter pack'
author = 'Canonical Group Ltd'
copyright = "%s, %s" % (datetime.date.today().year, author)
release = '1.0'

# Open Graph configuration - defines what is displayed in the website preview
ogp_site_url = "https://canonical-starter-pack.readthedocs-hosted.com/"
ogp_site_name = project
ogp_image = "https://assets.ubuntu.com/v1/253da317-image-document-ubuntudocs.svg"

# Update with the favicon for your product
html_favicon = ".sphinx/_static/favicon.png"

html_context = {
# Change to the link to your product website (without "https://")
"product_page": "documentation.ubuntu.com",
# Add your product tag to ".sphinx/_static" and change the path
# here (start with "/static")
"product_tag": "/_static/tag.png",
# Change to the discourse instance you want to be able to link to
# (use an empty value if you don't want to link)
"discourse": "https://discourse.ubuntu.com",
# Change to the GitHub info for your project
"github_url": "https://github.com/canonical/starter-pack",
# Change to the branch for this version of the documentation
"github_version": "main",
# Change to the folder that contains the documentation (usually "/" or "/docs/")
"github_folder": "/",
# Change to an empty value if your GitHub repo doesn't have issues enabled
"github_issues": "enabled"
}

# Used for related links - no need to change
if 'discourse' in html_context:
html_context['discourse_prefix'] = html_context['discourse'] + "/t/"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
############################################################
### Extensions
############################################################

extensions = [
'sphinx_design',
Expand All @@ -61,112 +28,128 @@
'myst_parser',
'sphinxcontrib.jquery'
]
extensions.extend(custom_extensions)

### Configuration for extensions

# Additional MyST syntax
myst_enable_extensions = [
"substitution",
"deflist"
'substitution',
'deflist'
]

# Used for related links
if 'discourse' in html_context:
html_context['discourse_prefix'] = html_context['discourse'] + '/t/'

############################################################
### General configuration
############################################################

exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.sphinx']
exclude_patterns.extend(custom_excludes)

rst_epilog = """
rst_epilog = '''
.. include:: /reuse/links.txt
"""
'''
if 'custom_rst_epilog' in locals():
rst_epilog = custom_rst_epilog

source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}

# Links to ignore when checking links
linkcheck_ignore = [
'http://127.0.0.1:8000'
]
if not 'conf_py_path' in html_context and 'github_folder' in html_context:
html_context['conf_py_path'] = html_context['github_folder']

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

# Find the current builder
builder = "dirhtml"
builder = 'dirhtml'
if '-b' in sys.argv:
builder = sys.argv[sys.argv.index('-b')+1]

# Setting templates_path for epub makes the build fail
if builder == "dirhtml" or builder == "html":
templates_path = [".sphinx/_templates"]
if builder == 'dirhtml' or builder == 'html':
templates_path = ['.sphinx/_templates']

# Theme configuration
html_theme = 'furo'
html_last_updated_fmt = ""
html_permalinks_icon = "¶"
html_last_updated_fmt = ''
html_permalinks_icon = '¶'
html_theme_options = {
"light_css_variables": {
"font-stack": "Ubuntu, -apple-system, Segoe UI, Roboto, Oxygen, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif",
"font-stack--monospace": "Ubuntu Mono, Consolas, Monaco, Courier, monospace",
"color-foreground-primary": "#111",
"color-foreground-secondary": "var(--color-foreground-primary)",
"color-foreground-muted": "#333",
"color-background-secondary": "#FFF",
"color-background-hover": "#f2f2f2",
"color-brand-primary": "#111",
"color-brand-content": "#06C",
"color-api-background": "#cdcdcd",
"color-inline-code-background": "rgba(0,0,0,.03)",
"color-sidebar-link-text": "#111",
"color-sidebar-item-background--current": "#ebebeb",
"color-sidebar-item-background--hover": "#f2f2f2",
"toc-font-size": "var(--font-size--small)",
"color-admonition-title-background--note": "var(--color-background-primary)",
"color-admonition-title-background--tip": "var(--color-background-primary)",
"color-admonition-title-background--important": "var(--color-background-primary)",
"color-admonition-title-background--caution": "var(--color-background-primary)",
"color-admonition-title--note": "#24598F",
"color-admonition-title--tip": "#24598F",
"color-admonition-title--important": "#C7162B",
"color-admonition-title--caution": "#F99B11",
"color-highlighted-background": "#EbEbEb",
"color-link-underline": "var(--color-background-primary)",
"color-link-underline--hover": "var(--color-background-primary)",
"color-version-popup": "#772953"
'light_css_variables': {
'font-stack': 'Ubuntu, -apple-system, Segoe UI, Roboto, Oxygen, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif',
'font-stack--monospace': 'Ubuntu Mono, Consolas, Monaco, Courier, monospace',
'color-foreground-primary': '#111',
'color-foreground-secondary': 'var(--color-foreground-primary)',
'color-foreground-muted': '#333',
'color-background-secondary': '#FFF',
'color-background-hover': '#f2f2f2',
'color-brand-primary': '#111',
'color-brand-content': '#06C',
'color-api-background': '#cdcdcd',
'color-inline-code-background': 'rgba(0,0,0,.03)',
'color-sidebar-link-text': '#111',
'color-sidebar-item-background--current': '#ebebeb',
'color-sidebar-item-background--hover': '#f2f2f2',
'toc-font-size': 'var(--font-size--small)',
'color-admonition-title-background--note': 'var(--color-background-primary)',
'color-admonition-title-background--tip': 'var(--color-background-primary)',
'color-admonition-title-background--important': 'var(--color-background-primary)',
'color-admonition-title-background--caution': 'var(--color-background-primary)',
'color-admonition-title--note': '#24598F',
'color-admonition-title--tip': '#24598F',
'color-admonition-title--important': '#C7162B',
'color-admonition-title--caution': '#F99B11',
'color-highlighted-background': '#EbEbEb',
'color-link-underline': 'var(--color-background-primary)',
'color-link-underline--hover': 'var(--color-background-primary)',
'color-version-popup': '#772953'
},
"dark_css_variables": {
"color-foreground-secondary": "var(--color-foreground-primary)",
"color-foreground-muted": "#CDCDCD",
"color-background-secondary": "var(--color-background-primary)",
"color-background-hover": "#666",
"color-brand-primary": "#fff",
"color-brand-content": "#06C",
"color-sidebar-link-text": "#f7f7f7",
"color-sidebar-item-background--current": "#666",
"color-sidebar-item-background--hover": "#333",
"color-admonition-background": "transparent",
"color-admonition-title-background--note": "var(--color-background-primary)",
"color-admonition-title-background--tip": "var(--color-background-primary)",
"color-admonition-title-background--important": "var(--color-background-primary)",
"color-admonition-title-background--caution": "var(--color-background-primary)",
"color-admonition-title--note": "#24598F",
"color-admonition-title--tip": "#24598F",
"color-admonition-title--important": "#C7162B",
"color-admonition-title--caution": "#F99B11",
"color-highlighted-background": "#666",
"color-link-underline": "var(--color-background-primary)",
"color-link-underline--hover": "var(--color-background-primary)",
"color-version-popup": "#F29879"
'dark_css_variables': {
'color-foreground-secondary': 'var(--color-foreground-primary)',
'color-foreground-muted': '#CDCDCD',
'color-background-secondary': 'var(--color-background-primary)',
'color-background-hover': '#666',
'color-brand-primary': '#fff',
'color-brand-content': '#06C',
'color-sidebar-link-text': '#f7f7f7',
'color-sidebar-item-background--current': '#666',
'color-sidebar-item-background--hover': '#333',
'color-admonition-background': 'transparent',
'color-admonition-title-background--note': 'var(--color-background-primary)',
'color-admonition-title-background--tip': 'var(--color-background-primary)',
'color-admonition-title-background--important': 'var(--color-background-primary)',
'color-admonition-title-background--caution': 'var(--color-background-primary)',
'color-admonition-title--note': '#24598F',
'color-admonition-title--tip': '#24598F',
'color-admonition-title--important': '#C7162B',
'color-admonition-title--caution': '#F99B11',
'color-highlighted-background': '#666',
'color-link-underline': 'var(--color-background-primary)',
'color-link-underline--hover': 'var(--color-background-primary)',
'color-version-popup': '#F29879'
},
}

############################################################
### Additional files
############################################################

html_static_path = ['.sphinx/_static']

html_css_files = [
'custom.css',
'header.css',
'github_issue_links.css',
]
html_css_files.extend(custom_html_css_files)

html_js_files = ['header-nav.js']
if "github_issues" in html_context and html_context["github_issues"]:
if 'github_issues' in html_context and html_context['github_issues'] and not disable_feedback_button:
html_js_files.append('github_issue_links.js')



# Set up redirects (https://documatt.gitlab.io/sphinx-reredirects/usage.html)
# For example: "explanation/old-name.html": "../how-to/prettify.html",
redirects = {}
html_js_files.extend(custom_html_js_files)
122 changes: 122 additions & 0 deletions custom_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import datetime

# Custom configuration for the Sphinx documentation builder.
# All configuration specific to your project should be done in this file.
#
# The file is included in the common conf.py configuration file.
# You can modify any of the settings below or add any configuration that
# is not covered by the common conf.py file.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

############################################################
### Project information
############################################################

# Product name
project = 'Documentation starter pack'
author = 'Canonical Group Ltd'

# Uncomment if your product uses release numbers
# release = '1.0'

# The default value uses the current year as the copyright year
copyright = '%s, %s' % (datetime.date.today().year, author)

## Open Graph configuration - defines what is displayed in the website preview
# The URL of the documentation output
ogp_site_url = 'https://canonical-starter-pack.readthedocs-hosted.com/'
# The documentation website name (usually the same as the product name)
ogp_site_name = project
# An image or logo that is used in the preview
ogp_image = 'https://assets.ubuntu.com/v1/253da317-image-document-ubuntudocs.svg'

# Update with the favicon for your product (default is the circle of friends)
html_favicon = '.sphinx/_static/favicon.png'

# (Some settings must be part of the html_context dictionary, while others
# are on root level. Don't move the settings.)
html_context = {

# Change to the link to your product website (without "https://")
'product_page': 'documentation.ubuntu.com',

# Add your product tag to ".sphinx/_static" and change the path
# here (start with "/static"), default is the circle of friends
'product_tag': '/_static/tag.png',

# Change to the discourse instance you want to be able to link to
# using the :discourse: metadata at the top of a file
# (use an empty value if you don't want to link)
'discourse': 'https://discourse.ubuntu.com',

# Change to the GitHub info for your project
'github_url': 'https://github.com/canonical/starter-pack',

# Change to the branch for this version of the documentation
'github_version': 'main',

# Change to the folder that contains the documentation
# (usually "/" or "/docs/")
'github_folder': '/',

# Change to an empty value if your GitHub repo doesn't have issues enabled.
# This will disable the feedback button and the issue link in the footer.
'github_issues': 'enabled'
}

############################################################
### Redirects
############################################################

# Set up redirects (https://documatt.gitlab.io/sphinx-reredirects/usage.html)
# For example: 'explanation/old-name.html': '../how-to/prettify.html',

redirects = {}

############################################################
### Link checker exceptions
############################################################

# Links to ignore when checking links

linkcheck_ignore = [
'http://127.0.0.1:8000'
]

############################################################
### Additions to default configuration
############################################################

## The following settings are appended to the default configuration.
## Use them to extend the default functionality.

# Add extensions
custom_extensions = []

# Add files or directories that should be excluded from processing.
custom_excludes = []

# Add CSS files (located in .sphinx/_static/)
custom_html_css_files = []

# Add JavaScript files (located in .sphinx/_static/)
custom_html_js_files = []

## The following settings override the default configuration.

# Specify a reST string that is included at the end of each file.
# If commented out, use the default (which pulls the reuse/links.txt
# file into each reST file).
# custom_rst_epilog = ''

# By default, the documentation includes a feedback button at the top.
# You can disable it by setting the following configuration to True.
disable_feedback_button = False

############################################################
### Additional configuration
############################################################

## Add any configuration that is not covered by the common conf.py file.
Loading

0 comments on commit 5afe29d

Please sign in to comment.