:py:`PROJECT_SUBTITLE` to the documentation
main page, similarly as
`shown here <{filename}/css/page-layout.rst#link-back-to-main-site-from-a-subsite>`_.
+:py:`INPUT: str` Base input directory. If not set, config
+ file base dir is used. Relative paths are
+ relative to config file base dir.
+:py:`OUTPUT: str` Where to save the output. Relative paths
+ are relative to :py:`INPUT`; if not set,
+ ``output/`` is used.
:py:`INPUT_MODULES: List[Any]` List of modules to generate the docs from.
Values can be either strings or module
objects. See `Module inspection`_ for more
:py:`INPUT_PAGES: List[str]` List of :abbr:`reST <reStructuredText>`
files for standalone pages. See `Pages`_
for more information.
-:py:`OUTPUT: str` Where to save the output. Relative paths
- relative are to the config file base dir;
- if not set, ``output/`` is used.
:py:`THEME_COLOR: str` Color for :html:`<meta name="theme-color" />`,
corresponding to the CSS style. If empty,
no :html:`<meta>` tag is rendered. See
:py:`FAVICON: str` Favicon URL, used to populate
:html:`<link rel="icon" />`. If empty, no
:html:`<link>` tag is rendered. Relative
- paths are searched relative to the config
- file base dir and to the ``python.py``
- script dir as a fallback. See
- `Theme selection`_ for more information.
+ paths are searched relative to :py:`INPUT`
+ and to the ``python.py`` script dir as a
+ fallback. See `Theme selection`_ for more
+ information.
:py:`STYLESHEETS: List[str]` List of CSS files to include. Relative
- paths are searched relative to the config
- file base dir and to the ``python.py``
- script dir as a fallback. See `Theme selection`_
- for more information.
+ paths are searched relative to :py:`INPUT`
+ and to the ``python.py`` script dir as a
+ fallback. See `Theme selection`_ for more
+ information.
:py:`HTML_HEADER: str` HTML code to put at the end of the
:html:`<head>` element. Useful for linking
arbitrary JavaScript code or, for example,
:py:`EXTRA_FILES: List[str]` List of extra files to copy (for example
additional CSS files that are :css:`@import`\ ed
from the primary one). Relative paths are
- searched relative to the config file base
- dir and to the ``python.py`` script dir as
- a fallback.
+ searched relative to :py:`INPUT` and to the
+ ``python.py`` script dir as a fallback.
:py:`LINKS_NAVBAR1: List[Any]` Left navbar column links. See
`Navbar links`_ for more information.
:py:`LINKS_NAVBAR2: List[Any]` Right navbar column links. See
'PROJECT_TITLE': 'My Python Project',
'PROJECT_SUBTITLE': None,
'MAIN_PROJECT_URL': None,
+ 'INPUT': None,
+ 'OUTPUT': 'output',
'INPUT_MODULES': [],
'INPUT_PAGES': [],
- 'OUTPUT': 'output',
'THEME_COLOR': '#22272e',
'FAVICON': 'favicon-dark.png',
'STYLESHEETS': [
# Set up the plugins
m.htmlsanity.register_mcss(config, env)
+ # Populate the INPUT, if not specified, make it absolute
+ if config['INPUT'] is None: config['INPUT'] = basedir
+ else: config['INPUT'] = os.path.join(basedir, config['INPUT'])
+
# Make the output dir absolute
- config['OUTPUT'] = os.path.join(basedir, config['OUTPUT'])
+ config['OUTPUT'] = os.path.join(config['INPUT'], config['OUTPUT'])
if not os.path.exists(config['OUTPUT']): os.makedirs(config['OUTPUT'])
# Guess MIME type of the favicon
state.class_index += [render_module(state, [module_name], module, env)]
for page in config['INPUT_PAGES']:
- state.page_index += render_page(state, [os.path.splitext(os.path.basename(page))[0]], os.path.join(basedir, page), env)
+ state.page_index += render_page(state, [os.path.splitext(os.path.basename(page))[0]], os.path.join(config['INPUT'], page), env)
# Recurse into the tree and mark every node that has nested modules with
# has_nestaable_children.
if urllib.parse.urlparse(i).netloc: continue
# If file is found relative to the conf file, use that
- if os.path.exists(os.path.join(basedir, i)):
- i = os.path.join(basedir, i)
+ if os.path.exists(os.path.join(config['INPUT'], i)):
+ i = os.path.join(config['INPUT'], i)
# Otherwise use path relative to script directory
else:
self.assertEqual(*self.actual_expected_contents('index.html'))
self.assertEqual(*self.actual_expected_contents('another.html'))
self.assertEqual(*self.actual_expected_contents('pages.html'))
+
+class PageInputSubdir(BaseTestCase):
+ def __init__(self, *args, **kwargs):
+ super().__init__(__file__, 'input_subdir', *args, **kwargs)
+
+ def test(self):
+ self.run_python({
+ 'INPUT': 'sub',
+ 'INPUT_PAGES': ['index.rst']
+ })
+ # The same output as Page, just the file is taken from elsewhere
+ self.assertEqual(*self.actual_expected_contents('index.html', '../page/index.html'))