Return the project name and merged configs from the calling project
and per-project defaults.
"""
- if not os.path.isfile('conf.yaml'):
+ if not os.path.isfile("conf.yaml"):
raise IOError("No conf.yaml file found at: {}".format(os.getcwd()))
- with open('conf.yaml', 'r') as f:
+ with open("conf.yaml", "r") as f:
local_config = yaml.safe_load(f)
- project_cfg = local_config.get('project_cfg', None)
+ project_cfg = local_config.get("project_cfg", None)
- _, docs_path, _ = imp.find_module('docs_conf')
+ _, docs_path, _ = imp.find_module("docs_conf")
- default_cfg = os.path.join(docs_path, 'defaults', 'default.yaml')
- with open(os.path.join(docs_path, default_cfg), 'r') as f:
+ default_cfg = os.path.join(docs_path, "defaults", "default.yaml")
+ with open(os.path.join(docs_path, default_cfg), "r") as f:
effective_config = yaml.safe_load(f)
- project_cfg_file = os.path.join(docs_path, 'defaults', '{}.yaml'.format(project_cfg))
+ project_cfg_file = os.path.join(
+ docs_path, "defaults", "{}.yaml".format(project_cfg)
+ )
if os.path.isfile(project_cfg_file):
- with open(os.path.join(docs_path, project_cfg_file), 'r') as f:
+ with open(os.path.join(docs_path, project_cfg_file), "r") as f:
_project_cfg_data = yaml.safe_load(f)
effective_config = _merge_yaml(effective_config, _project_cfg_data)
cfg = collect_project_and_config()
# Parse the config and pull in sphinx conf.py settings
-project = cfg.get('project')
-version = cfg.get('version')
-release = cfg.get('release', version)
-author = cfg.get('author')
-copyright = cfg.get('copyright')
-
-needs_sphinx = cfg.get('needs_sphinx', '1.0')
-exclude_patterns = cfg.get('exclude_patterns', [])
-extensions = cfg.get('extensions', [])
-language = cfg.get('language', None)
-master_doc = cfg.get('master_doc', 'index')
-pygments_style = cfg.get('pygments_style', 'sphinx')
-source_suffix = cfg.get('source_suffix', '.rst')
-templates_path = cfg.get('templates_path', ['_templates'])
-todo_include_todos = cfg.get('todo_include_todos', False)
-
-html_extra_path = cfg.get('html_extra_path', [])
-html_favicon = cfg.get('html_favicon', None)
-html_logo = cfg.get('html_logo', None)
-html_sidebars = cfg.get('html_sidebars', {'**': ['localtoc.html', 'relations.html'], })
-html_static_path = cfg.get('html_static_path', [])
-html_theme = cfg.get('html_theme', 'bootstrap')
-html_theme_options = cfg.get('html_theme_options', {
- 'bootswatch_theme': "cerulean",
- 'navbar_sidebarrel': False,
- 'source_link_position': "footer",
-})
-if html_theme == 'opnfv':
+project = cfg.get("project")
+version = cfg.get("version")
+release = cfg.get("release", version)
+author = cfg.get("author")
+copyright = cfg.get("copyright")
+
+needs_sphinx = cfg.get("needs_sphinx", "1.0")
+exclude_patterns = cfg.get("exclude_patterns", [])
+extensions = cfg.get("extensions", [])
+language = cfg.get("language", None)
+master_doc = cfg.get("master_doc", "index")
+pygments_style = cfg.get("pygments_style", "sphinx")
+source_suffix = cfg.get("source_suffix", ".rst")
+templates_path = cfg.get("templates_path", ["_templates"])
+todo_include_todos = cfg.get("todo_include_todos", False)
+
+html_extra_path = cfg.get("html_extra_path", [])
+html_favicon = cfg.get("html_favicon", None)
+html_logo = cfg.get("html_logo", None)
+html_sidebars = cfg.get("html_sidebars", {"**": ["localtoc.html", "relations.html"]})
+html_static_path = cfg.get("html_static_path", [])
+html_theme = cfg.get("html_theme", "bootstrap")
+html_theme_options = cfg.get(
+ "html_theme_options",
+ {
+ "bootswatch_theme": "cerulean",
+ "navbar_sidebarrel": False,
+ "source_link_position": "footer",
+ },
+)
+if html_theme == "opnfv":
import sphinx_opnfv_theme
+
html_theme_path = sphinx_opnfv_theme.get_html_theme_path()
else:
- html_theme_path = cfg.get('html_theme_path', sphinx_bootstrap_theme.get_html_theme_path())
-htmlhelp_basename = cfg.get('htmlhelp_basename', 'DocsConf')
+ html_theme_path = cfg.get(
+ "html_theme_path", sphinx_bootstrap_theme.get_html_theme_path()
+ )
+htmlhelp_basename = cfg.get("htmlhelp_basename", "DocsConf")
intersphinx_mapping = {
- 'common-packer': ('https://docs.releng.linuxfoundation.org/projects/common-packer/en/latest/', None),
- 'global-jjb': ('https://docs.releng.linuxfoundation.org/projects/global-jjb/en/latest/', None),
- 'lfdocs': ('https://docs.releng.linuxfoundation.org/en/latest/', None),
- 'lfdocs-conf': ('https://docs.releng.linuxfoundation.org/projects/lfdocs-conf/en/latest/', None),
- 'lftools': ('https://docs.releng.linuxfoundation.org/projects/lftools/en/latest/', None),
- 'python': ('https://docs.python.org/3', None),
+ "common-packer": (
+ "https://docs.releng.linuxfoundation.org/projects/common-packer/en/latest/",
+ None,
+ ),
+ "global-jjb": (
+ "https://docs.releng.linuxfoundation.org/projects/global-jjb/en/latest/",
+ None,
+ ),
+ "lfdocs": ("https://docs.releng.linuxfoundation.org/en/latest/", None),
+ "lfdocs-conf": (
+ "https://docs.releng.linuxfoundation.org/projects/lfdocs-conf/en/latest/",
+ None,
+ ),
+ "lftools": (
+ "https://docs.releng.linuxfoundation.org/projects/lftools/en/latest/",
+ None,
+ ),
+ "python": ("https://docs.python.org/3", None),
}
import pytest
import sys
+
@pytest.fixture()
def config(tmpdir):
"""
Create a basic conf.py and conf.cfg file for each test
"""
# Create the base 'conf.py'
- confpy = tmpdir.join('conf.py')
+ confpy = tmpdir.join("conf.py")
confpy.write("from docs_conf.conf import *")
# Create conf.cfg file with test defaults
# TODO: Make this dynamic so each test can set their own conf.cfg
# config.
- confcfg = tmpdir.join('conf.yaml')
+ confcfg = tmpdir.join("conf.yaml")
confcfg.write("---\nproject: myproject\nauthor: Pythonista")
# Change to the tmpdir location so relative file lookups succeed
# Import the 'conf.py' file
sys.path.append(str(tmpdir))
- conf_module = importlib.import_module('conf')
+ conf_module = importlib.import_module("conf")
return conf_module
+
def test_config(config):
"""
Assert some basic assumption about how configurations are pulled in
"""
- assert config.project == 'myproject'
- assert config.author == 'Pythonista'
- #assert 'latex_documents' in dir(config)
+ assert config.project == "myproject"
+ assert config.author == "Pythonista"
+ # assert 'latex_documents' in dir(config)
+
def test_defaults(config):
"""
# TODO
assert True
+
def test_project_override(config):
"""
Test that setting sphinx.project pulls in the project specific
# TODO
assert True
+
def test_theme_import(config):
"""
Test setting sphinx.html_theme_module imports the correct theme