Python-sphinx Extension, Extra Html Files
I am working on extension for sphinx doc generator.
I would like to add some html, js, css and json files to html build of the doc.
They are not part of template and they should not be affected by anything in sphinx template. They are just viewer for files which I would like to add in downloads folder. (I also do not how.)
How to include extra html files in sphinx extension? JS/CSS can be added as described there https://docs.readthedocs.io/en/latest/guides/adding-custom-css.html but there is not a function for html.
def setup(app):
app.add_stylesheet('css/custom.css')
app.add_javascript("js/custom.js")
# and custom html or any generic file ?
Answer
There is a html_static_path in conf.py (it is list of paths). There you can add you static files (by folder).
In order to dynamically generate static files. There is not a explicit way function to add static files. Instead static files can be just copied by python to html_static_path.
Where to find html_static_path?
class Node(nodes.TextElement):
@staticmethod
def visit_html(self, node),
self.document.settings.env.config.html_static_path
class Direc(Directive):
def run(self):
self.state.document.settings.env.config.html_static_path
Also html_static_path is relative to
self.document.settings.env.app.confdir
And build dir can be obrained by
document.settings.env.app.builder.outdir
There is more of html related config in http://www.sphinx-doc.org/en/master/usage/configuration.html
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module