# sphinx-doc sphinx-doc is a way to write ebooks, documentation, or websites once and export to your desired output. Exported formats include epub, html, pdf, etc. Also checkout my other repository [publishing-workshop](https://github.com/TechnologyClassroom/publishing-workshop) which is a simple skeleton for self-publishing with sphinx that I used in a small presentation. ## Creating a new sphinx-doc project Install sphinx-doc according to their documentation. Open a terminal. Navigate to a new directory for your project. Run the sphinx-quickstart program. ```sphinx-quickstart``` I used these answers: ``` > Root path for the documentation [.]: . > Separate source and build directories (y/n) [n]: y > Name prefix for templates and static dir [_]: _ > Project name: InsertProjectName > Author name(s): InsertAuthorOrAuthorsHere > Project version []: 1.0 > Project release [1.0]: 1.0 > Project language [en]: en > Source file suffix [.rst]: .rst > Name of your master document (without suffix) [index]: index > Do you want to use the epub builder (y/n) [n]: y > autodoc: automatically insert docstrings from modules (y/n) [n]: y > doctest: automatically test code snippets in doctest blocks (y/n) [n]: n > intersphinx: link between Sphinx documentation of different projects (y/n) [n]: n > todo: write "todo" entries that can be shown or hidden on build (y/n) [n]: n > coverage: checks for documentation coverage (y/n) [n]: n > imgmath: include math, rendered as PNG or SVG images (y/n) [n]: n > mathjax: include math, rendered in the browser by MathJax (y/n) [n]: n > ifconfig: conditional inclusion of content based on config values (y/n) [n]: n > viewcode: include links to the source code of documented Python objects (y/n) [n]: n > githubpages: create .nojekyll file to publish the document on GitHub pages (y/n) [n]: n > Create Makefile? (y/n) [y]: y > Create Windows command file? (y/n) [y]: y ``` After this the directory trees are created. Edit ./source/index.rst to modify the document. Build a new epub into the build directory with this command: ```sphinx-build -b epub source build``` ## conf.py [config.py epub options](http://www.sphinx-doc.org/en/stable/config.html#options-for-epub-output) An example conf.py file I have used can be found [here](https://github.com/GhostCityGames/Midnight-Riders/blob/master/source/conf.py). ``` # epub cover image epub_cover = ('_static/mr-cover.png', '') # epub index epub_use_index = False # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = False ``` ## Templates Themes are located in the /usr/share/sphinx/themes/ folder. The default theme can be found in the /usr/share/sphinx/themes/basic folder. [Templating](http://www.sphinx-doc.org/en/stable/templating.html) [Theming at tinkerer.me](http://tinkerer.me/doc/theming.html) Adding creative commons TP from https://groups.google.com/forum/#!topic/sphinx-users/f3Yl45l1KYg suggests overwriting the footer with a template: Template modifiers can be placed in the file ./source/_templates/layout.html CC BY-SA 4.0 INTL ``` {% extends "!layout.html" %} {%- block footer %} {{ super() }}
{%- endblock %} ``` Removing the navigation links at the top of each page ``` {% block relbar1 %}{% endblock %} ``` ## Examples https://github.com/GhostCityGames/Midnight-Riders http://www.sphinx-doc.org/en/stable/tutorial.html https://github.com/sphinx-doc/sphinx/blob/master/EXAMPLES Frontend : https://docs.chef.io/index.html Backend: https://github.com/chef/chef-web-docs/tree/master/chef_master/source https://github.com/yoloseem/awesome-sphinxdoc ## Code Snippets ``` Adding a picture .. image:: /_static/picture.png :width: 700px :align: center .. end_tag