Skip to content

Commit

Permalink
Initial reST output for Sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
macfreek committed Apr 28, 2012
1 parent 83688b9 commit eefbd26
Show file tree
Hide file tree
Showing 4 changed files with 1,044 additions and 21 deletions.
51 changes: 32 additions & 19 deletions doc/Makefile
Expand Up @@ -6,6 +6,7 @@ SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER = a4
BUILDDIR = build
WIKIDIR = ../../NBT.wiki

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
Expand All @@ -14,29 +15,31 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -c
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext rst

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " wiki to make ReST files for the NBT wiki"
# @echo " dirhtml to make HTML files named index.html in directories"
# @echo " singlehtml to make a single large HTML file"
# @echo " pickle to make pickle files"
# @echo " json to make JSON files"
# @echo " htmlhelp to make HTML files and a HTML help project"
# @echo " qthelp to make HTML files and a qthelp project"
# @echo " devhelp to make HTML files and a Devhelp project"
# @echo " epub to make an epub"
# @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
# @echo " latexpdf to make LaTeX files and run them through pdflatex"
# @echo " text to make text files"
# @echo " man to make manual pages"
# @echo " texinfo to make Texinfo files"
# @echo " info to make Texinfo files and run them through makeinfo"
# @echo " gettext to make PO message catalogs"
# @echo " rst to make ReST files"
# @echo " changes to make an overview of all changed/added/deprecated items"
# @echo " linkcheck to check all external links for integrity"
# @echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
-rm -rf $(BUILDDIR)/*
Expand Down Expand Up @@ -136,6 +139,16 @@ gettext:
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

rst:
$(SPHINXBUILD) -b rst $(I18NSPHINXOPTS) $(BUILDDIR)/rst
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/rst."

wiki:
$(SPHINXBUILD) -b rst $(I18NSPHINXOPTS) $(WIKIDIR)
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/rst."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
Expand Down
30 changes: 28 additions & 2 deletions doc/conf.py
Expand Up @@ -20,7 +20,7 @@

# Make sure we are importing the current NBT, and not an old version installed
# in the site-packages
parentdir = os.path.realpath(os.path.join(os.path.dirname(__file__),os.pardir))
parentdir = os.path.abspath(os.path.join(os.path.dirname(__file__),os.pardir))
if not os.path.exists(os.path.join(parentdir, 'nbt')):
raise ImportError("Can not find nbt module at %s" % parentdir)
if os.path.exists(os.path.join(parentdir, 'examples')):
Expand All @@ -30,14 +30,18 @@
sys.path.insert(1, parentdir)
import nbt

# Include extensions directory
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), 'sphinxext')))

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'restbuilder']
#, 'sphinx.ext.viewcode'

# Add any paths that contain templates here, relative to this directory.
templates_path = ['templates']
Expand Down Expand Up @@ -208,6 +212,28 @@ def setup(app):
htmlhelp_basename = 'NBTdoc'


# -- Options for reST output ---------------------------------------------------

# This is the file name suffix for reST files
rst_file_suffix = '.rst'

# This is the suffix for links to other reST files
rst_link_suffix = ''

# If set, function that changes the changes the reST file name.
# Default is docname + rst_file_suffix
def rst_file_transform(docname):
if docname == 'index':
docname = 'home'
return docname.title() + rst_file_suffix

# If set, function that changes the changes the reST file name to a URI.
# Default is docname + rst_link_suffix
def rst_link_transform(docname):
if docname == 'index':
return 'wiki'
return 'wiki/' + docname.title()

# -- Options for LaTeX output --------------------------------------------------

# The paper size ('letter' or 'a4').
Expand Down
14 changes: 14 additions & 0 deletions doc/sphinxext/__init__.py
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
"""
sphinxcontrib
~~~~~~~~~~~~~
This package is a namespace package that contains all extensions
distributed in the ``sphinx-contrib`` distribution.
:copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""

__import__('pkg_resources').declare_namespace(__name__)

0 comments on commit eefbd26

Please sign in to comment.