From: <jd...@us...> - 2009-08-11 12:08:34
|
Revision: 7469 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7469&view=rev Author: jdh2358 Date: 2009-08-11 12:08:25 +0000 (Tue, 11 Aug 2009) Log Message: ----------- moved to trunk Added Paths: ----------- trunk/sampledoc_tut/Makefile trunk/sampledoc_tut/_build/ trunk/sampledoc_tut/_static/ trunk/sampledoc_tut/_static/basic_screenshot.png trunk/sampledoc_tut/_static/fancy_screenshot.png trunk/sampledoc_tut/_static/logo.png trunk/sampledoc_tut/_templates/ trunk/sampledoc_tut/cheatsheet.rst trunk/sampledoc_tut/conf.py trunk/sampledoc_tut/custom_look.rst trunk/sampledoc_tut/emacs_help.rst trunk/sampledoc_tut/extensions.rst trunk/sampledoc_tut/getting_started.rst trunk/sampledoc_tut/index.rst trunk/sampledoc_tut/pyplots/ trunk/sampledoc_tut/sphinxext/ Removed Paths: ------------- trunk/sampledoc_tut/_static/basic_screenshot.png Copied: trunk/sampledoc_tut/Makefile (from rev 7463, trunk/py4science/examples/sphinx_qs/Makefile) =================================================================== --- trunk/sampledoc_tut/Makefile (rev 0) +++ trunk/sampledoc_tut/Makefile 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,93 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest + +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 " 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 " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @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 _build/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html + @echo + @echo "Build finished. The HTML pages are in _build/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml + @echo + @echo "Build finished. The HTML pages are in _build/dirhtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in _build/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in _build/qthelp, like this:" + @echo "# qcollectiongenerator _build/qthelp/sampledoc.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile _build/qthelp/sampledoc.qhc" + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex + @echo + @echo "Build finished; the LaTeX files are in _build/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes + @echo + @echo "The overview file is in _build/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in _build/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in _build/doctest/output.txt." + +sf: + cd _build/html; \ + rsync -avz . jdh2358,mat...@we...:/home/groups/m/ma/matplotlib/htdocs/sampledoc -essh --cvs-exclude + Deleted: trunk/sampledoc_tut/_static/basic_screenshot.png =================================================================== (Binary files differ) Copied: trunk/sampledoc_tut/_static/basic_screenshot.png (from rev 7463, trunk/py4science/examples/sphinx_qs/_static/basic_screenshot.png) =================================================================== (Binary files differ) Copied: trunk/sampledoc_tut/_static/fancy_screenshot.png (from rev 7462, trunk/py4science/examples/sphinx_qs/_static/fancy_screenshot.png) =================================================================== (Binary files differ) Copied: trunk/sampledoc_tut/_static/logo.png (from rev 7461, trunk/py4science/examples/sphinx_qs/_static/logo.png) =================================================================== (Binary files differ) Copied: trunk/sampledoc_tut/cheatsheet.rst (from rev 7460, trunk/py4science/examples/sphinx_qs/cheatsheet.rst) =================================================================== --- trunk/sampledoc_tut/cheatsheet.rst (rev 0) +++ trunk/sampledoc_tut/cheatsheet.rst 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,98 @@ +.. _cheat-sheet: + +****************** +Sphinx cheat sheet +****************** + +Here is a quick and dirty cheat sheet for some common stuff you want +to do in sphinx and ReST. You can see the literal source for this +file at :ref:`cheatsheet +-literal`. + + +.. _formatting-text: + +Formatting text +=============== + +You use inline markup to make text *italics*, **bold**, or ``monotype``. + +You can represent code blocks fairly easily:: + + import numpy as np + x = np.random.rand(12) + +Or literally include code: + +.. literalinclude:: pyplots/ellipses.py + +.. _making-a-list: + +Making a list +============= + +It is easy to make lists in rest + +Bullet points +------------- + +This is a subsection making bullet points + +* point A + +* point B + +* point C + + +Enumerated points +------------------ + +This is a subsection making numbered points + +#. point A + +#. point B + +#. point C + + +.. _making-a-table: + +Making a table +============== + +This shows you how to make a table -- if you only want to make a list see :ref:`making-a-list`. + +================== ============ +Name Age +================== ============ +John D Hunter 40 +Cast of Thousands 41 +And Still More 42 +================== ============ + +.. _making-links: + +Making links +============ + +It is easy to make a link to `yahoo <http://yahoo.com>`_ or to some +section inside this document (see :ref:`making-a-table`) or another +document. + +You can also reference classes, modules, functions, etc that are +documented using the sphinx `autodoc +<http://sphinx.pocoo.org/ext/autodoc.html>`_ facilites. For example, +see the module :mod:`matplotlib.backend_bases` documentation, or the +class :class:`~matplotlib.backend_bases.LocationEvent`, or the method +:meth:`~matplotlib.backend_bases.FigureCanvasBase.mpl_connect`. + + + +.. _cheatsheet-literal: + +This file +========= + +.. literalinclude:: cheatsheet.rst Copied: trunk/sampledoc_tut/conf.py (from rev 7461, trunk/py4science/examples/sphinx_qs/conf.py) =================================================================== --- trunk/sampledoc_tut/conf.py (rev 0) +++ trunk/sampledoc_tut/conf.py 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,202 @@ +# -*- coding: utf-8 -*- +# +# sampledoc documentation build configuration file, created by +# sphinx-quickstart on Tue Aug 11 05:04:40 2009. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +sys.path.append(os.path.abspath('sphinxext')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['matplotlib.sphinxext.mathmpl', + 'matplotlib.sphinxext.only_directives', + 'matplotlib.sphinxext.plot_directive', + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'ipython_console_highlighting', + 'inheritance_diagram', + 'numpydoc'] + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'sampledoc' +copyright = u'2009, jdh' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1.0' +# The full version, including alpha/beta/rc tags. +release = '1.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'sampledocdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'sampledoc.tex', u'sampledoc Documentation', + u'jdh', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True Copied: trunk/sampledoc_tut/custom_look.rst (from rev 7465, trunk/py4science/examples/sphinx_qs/custom_look.rst) =================================================================== --- trunk/sampledoc_tut/custom_look.rst (rev 0) +++ trunk/sampledoc_tut/custom_look.rst 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,62 @@ +.. _custom_look: + + +****************************************** +Customizing the look and feel of the site +****************************************** + +The `sphinx <http://sphinx.pocoo.org/>`_ site itself looks better than +the sites created with the default css, so here we'll invoke Tufte's +phrase "Intelligence imitates but genious steals and grab their css +and part of their layout. As before, you can either get the required +files :file:`_static/default.css`, :file:`_templates:layout.html` and +:file:`_static\logo.png` from the website or svn (see +:ref:`fetching-the-data`). Since I did a svn checkout before, I will +just copy the stuff I need from there:: + + home:~/tmp/sampledoc> cp ../sampledoc_tut/_static/default.css _static/ + home:~/tmp/sampledoc> cp ../sampledoc_tut/_templates/layout.html _templates/ + home:~/tmp/sampledoc> cp ../sampledoc_tut/_static/logo.png _static/ + home:~/tmp/sampledoc> ls _static/ _templates/ + _static/: + basic_screenshot.png default.css logo.png + + _templates/: + layout.html + +Sphinx will automatically pick up the css and layout html files since +we put them in the default places with the default names, but we have +to manually include the logo in our :file:`layout.html`. Let's take a +look at the layout file: the first part puts a horizontal navigation +bar at the top of our page, like you see on the `sphinx +<http://sphinx.pocoo.org>`_ and `matplotlib +<http://matplotlib.sourceforge.net/>`_ sites, the second part includes +a logo that when we click on it will take us `home` and the last part +moves the vertical navigation panels to the right side of the page:: + + {% extends "!layout.html" %} + + + {% block rootrellink %} + <li><a href="{{ pathto('index') }}">home</a>| </li> + <li><a href="{{ pathto('search') }}">search</a>| </li> + <li><a href="{{ pathto('contents') }}">documentation </a> »</li> + {% endblock %} + + + {% block relbar1 %} + + <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> + <a href="{{ pathto('index') }}"><img src="{{ + pathto("_static/logo.png", 1) }}" border="0" alt="sampledoc"/></a> + </div> + {{ super() }} + {% endblock %} + + {# put the sidebar before the body #} + {% block sidebar1 %}{{ sidebar() }}{% endblock %} + {% block sidebar2 %}{% endblock %} + +Once you rebuild the site with a ``make html`` and reload the page in your browser, you should see a fancier site that looks like this + +.. image:: _static/fancy_screenshot.png Copied: trunk/sampledoc_tut/emacs_help.rst (from rev 7464, trunk/py4science/examples/sphinx_qs/emacs_help.rst) =================================================================== --- trunk/sampledoc_tut/emacs_help.rst (rev 0) +++ trunk/sampledoc_tut/emacs_help.rst 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,40 @@ +.. _working-with-emacs: + +******************* +Emacs ReST support +******************* + +Emacs helpers +============= + +There is an emacs mode `rst.el +<http://docutils.sourceforge.net/tools/editors/emacs/rst.el>`_ which +automates many important ReST tasks like building and updateing +table-of-contents, and promoting or demoting section headings. Here +is the basic ``.emacs`` configuration:: + + (require 'rst) + (setq auto-mode-alist + (append '(("\\.txt$" . rst-mode) + ("\\.rst$" . rst-mode) + ("\\.rest$" . rst-mode)) auto-mode-alist)) + + +Some helpful functions:: + + C-c TAB - rst-toc-insert + + Insert table of contents at point + + C-c C-u - rst-toc-update + + Update the table of contents at point + + C-c C-l rst-shift-region-left + + Shift region to the left + + C-c C-r rst-shift-region-right + + Shift region to the right + Copied: trunk/sampledoc_tut/extensions.rst (from rev 7465, trunk/py4science/examples/sphinx_qs/extensions.rst) =================================================================== --- trunk/sampledoc_tut/extensions.rst (rev 0) +++ trunk/sampledoc_tut/extensions.rst 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,154 @@ +.. _extensions: + + +**************************************************** +Sphinx extensions for embedded plots, math and more +**************************************************** + +Sphinx is written in python, and supports the ability to write custom +extensions. We've written a few for the matplotlib documentation, +some of which are part of matplotlib itself in the +matplotlib.sphinxext module, some of which are included only in the +sphinx doc directory, and there are other extensions written by other +groups, eg numpy and ipython. We're collecting these in this tutorial +and showing you how to install and use them for your own project. +First let's grab the python extension files from the :file:`sphinxext` +directory from svn (see :ref:`fetching-the-data`, and install them in +our :file:`sampledoc` project :file:`sphinxext` directory:: + + home:~/tmp/sampledoc> mkdir sphinxext + home:~/tmp/sampledoc> cp ../sampledoc_tut/sphinxext/*.py sphinxext/ + home:~/tmp/sampledoc> ls sphinxext/ + apigen.py inheritance_diagram.py + docscrape.py ipython_console_highlighting.py + docscrape_sphinx.py numpydoc.py + +In addition to the builtin matplotlib extensions for embedding pyplot +plots and rendering math with matplotlib's native math engine, we also +have extensions for syntax highlighting ipython sessions, making +inhertiance diagrams, and more. + +We need to inform sphinx of our new extensions in the :file:`conf.py` +file by adding the following. First we tell it where to find the extensions:: + + # If your extensions are in another directory, add it here. If the + # directory is relative to the documentation root, use + # os.path.abspath to make it absolute, like shown here. + sys.path.append(os.path.abspath('sphinxext')) + +And then we tell it what extensions to load:: + + # Add any Sphinx extension module names here, as strings. They can + # be extensions coming with Sphinx (named 'sphinx.ext.*') or your + # custom ones. + extensions = ['matplotlib.sphinxext.mathmpl', + 'matplotlib.sphinxext.only_directives', + 'matplotlib.sphinxext.plot_directive', + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'ipython_console_highlighting', + 'inheritance_diagram', + 'numpydoc'] + + +Now let's look at some of these in action. You can see the literal +source for this file at :ref:`extensions-literal`. + + +.. _ipython-highlighting: + +ipython sessions +================ + +Michael Droettboom contributed a sphinx extension which does pygments +syntax highlighting on ipython sessions + +.. sourcecode:: ipython + + In [69]: lines = plot([1,2,3]) + + In [70]: setp(lines) + alpha: float + animated: [True | False] + antialiased or aa: [True | False] + ...snip + +This support is included in this template, but will also be included +in a future version of Pygments by default. + +.. _using-math: + +Using math +========== + +In sphinx you can include inline math :math:`x\leftarrow y\ x\forall +y\ x-y` or display math + +.. math:: + + W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right] + +This documentation framework includes a Sphinx extension, +:file:`sphinxext/mathmpl.py`, that uses matplotlib to render math +equations when generating HTML, and LaTeX itself when generating a +PDF. This can be useful on systems that have matplotlib, but not +LaTeX, installed. To use it, add ``mathmpl`` to the list of +extensions in :file:`conf.py`. + +Current SVN versions of Sphinx now include built-in support for math. +There are two flavors: + + - pngmath: uses dvipng to render the equation + + - jsmath: renders the math in the browser using Javascript + +To use these extensions instead, add ``sphinx.ext.pngmath`` or +``sphinx.ext.jsmath`` to the list of extensions in :file:`conf.py`. + +All three of these options for math are designed to behave in the same +way. + +.. _emacs-helpers: + +Inserting matplotlib plots +========================== + +Inserting automatically-generated plots is easy. Simply put the +script to generate the plot in the :file:`pyplots` directory, and +refer to it using the ``plot`` directive. To include the source code +for the plot in the document, pass the ``include-source`` parameter:: + + .. plot:: pyplots/ellipses.py + :include-source: + +In the HTML version of the document, the plot includes links to the +original source code, a high-resolution PNG and a PDF. In the PDF +version of the document, the plot is included as a scalable PDF. + +.. plot:: pyplots/ellipses.py + :include-source: + +Inheritance diagrams +==================== + +Inheritance diagrams can be inserted directly into the document by +providing a list of class or module names to the +``inheritance-diagram`` directive. + +For example:: + + .. inheritance-diagram:: codecs + +produces: + +.. inheritance-diagram:: codecs + + +.. _extensions-literal: + +This file +========= + +.. literalinclude:: extensions.rst + + Copied: trunk/sampledoc_tut/getting_started.rst (from rev 7465, trunk/py4science/examples/sphinx_qs/getting_started.rst) =================================================================== --- trunk/sampledoc_tut/getting_started.rst (rev 0) +++ trunk/sampledoc_tut/getting_started.rst 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,105 @@ +.. _getting_started: + + +*************** +Getting started +*************** + +.. _installing-docdir: + +Installing your doc directory +============================= + +You may already have sphinx `sphinx <http://sphinx.pocoo.org/>`_ +installed -- you can check by doing:: + + python -c 'import sphinx' + +If that fails grab the latest version of and install it with:: + + > sudo easy_install sphinx + +Now you are ready to build a template for your docs, using +sphinx-quickstart:: + + > sphinx-quickstart + +accepting most of the defaults. I choose "sampledoc" as the name of my +project. cd into your new directory and check the contents:: + + home:~/tmp/sampledoc> ls + Makefile _static conf.py + _build _templates index.rst + +The index.rst is the master ReST for your project, but before adding +anything, let's see if we can build some html:: + + make html + +If you now point your browser to :file:`_build/html/index.html`, you +should see a basic spinx site. + +.. image:: _static/basic_screenshot.png + +.. _fetching-the-data: + +Fetching the data +----------------- + +Now we will start to customize out docs. Grab a couple of files from +the `web site +<http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/sampledoc_tut/>`_ +or svn. You will need :file:`getting_started.rst` and +:file:`_static/basic_screenshot.png`. All of the files live in the +"completed" version of this tutorial, but since this is a tutorial, +we'll just grab them one at a time, so you can learn what needs to be +changed where. Since we have more files to come, I'm going to grab +the whole svn directory and just copy the files I need over for now. +First, I'll cd to the directory containing my project, and get the +"finished" product, and then copy in just the files I need:: + + home:~/tmp/sampledoc> pwd + /Users/jdhunter/tmp/sampledoc + home:~/tmp/sampledoc> cd .. + home:~/tmp> svn co + https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/\ + sampledoc_tut + A sampledoc_tut/cheatsheet.rst + A sampledoc_tut/_static + A sampledoc_tut/_static/basic_screenshot.png + A sampledoc_tut/conf.py + A sampledoc_tut/Makefile + A sampledoc_tut/_templates + A sampledoc_tut/_build + A sampledoc_tut/getting_started.rst + A sampledoc_tut/index.rst + Checked out revision 7449. + home:~/tmp> cp sampledoc_tut/getting_started.rst sampledoc/ + home:~/tmp> cp sampledoc_tut/_static/basic_screenshot.png sampledoc/_static/ + +Now we are ready to rebuild the docs. We used the image directory to +include to the screenshot above with:: + + .. image:: _static/basic_screenshot.png + +The last step is to modify :file:`index.rst` to include the +getting_started file (be careful with the indentation, the +"getting_started" should line up with the ':' in ``:maxdepth``:: + + Contents: + + .. toctree:: + :maxdepth: 2 + + getting_started.rst + +and then rebuild the docs with ``make html``. When you reload the +page, you should see a link to the "Getting Started" docs, and in +there this page with the screenshot. `Voila!` + + +Next we'll customize the look and feel of our site to give it a logo, +some custom css, and update the navigation panels to look more like +the `sphinx <http://sphinx.pocoo.org/>`_ site itself -- see +:ref:`custom_look`. + Copied: trunk/sampledoc_tut/index.rst (from rev 7465, trunk/py4science/examples/sphinx_qs/index.rst) =================================================================== --- trunk/sampledoc_tut/index.rst (rev 0) +++ trunk/sampledoc_tut/index.rst 2009-08-11 12:08:25 UTC (rev 7469) @@ -0,0 +1,35 @@ +.. sampledoc documentation master file, created by + sphinx-quickstart on Tue Aug 11 05:04:40 2009. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +sampledoc tutorial +================== + +This is a tutorial introduction to quickly get you up and running with +your own sphinx documentation system. We'll cover everything from +installing sphinx, to customizing the look and feel, to using custom +extensions for embedding plots, inheritance diagrams, syntax +highlighted ipython sessions and more. If you follow along the +tutorial, you'll start with nothing and end up with this site! The +source code for this tutorial lives in mpl svn (see +:ref:`fetching-the-data`) + +Contents: + +.. toctree:: + :maxdepth: 2 + + getting_started.rst + custom_look.rst + extensions.rst + cheatsheet.rst + emacs_help.rst + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-08-11 12:29:59
|
Revision: 7470 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7470&view=rev Author: jdh2358 Date: 2009-08-11 12:29:52 +0000 (Tue, 11 Aug 2009) Log Message: ----------- proper attribution Modified Paths: -------------- trunk/sampledoc_tut/Makefile trunk/sampledoc_tut/conf.py trunk/sampledoc_tut/getting_started.rst trunk/sampledoc_tut/index.rst Modified: trunk/sampledoc_tut/Makefile =================================================================== --- trunk/sampledoc_tut/Makefile 2009-08-11 12:08:25 UTC (rev 7469) +++ trunk/sampledoc_tut/Makefile 2009-08-11 12:29:52 UTC (rev 7470) @@ -91,3 +91,9 @@ cd _build/html; \ rsync -avz . jdh2358,mat...@we...:/home/groups/m/ma/matplotlib/htdocs/sampledoc -essh --cvs-exclude + +sfpdf: + cd _build/latex; \ + scp sampledoc.pdf jdh2358,mat...@we...:/home/groups/m/ma/matplotlib/htdocs/sampledoc/ + + Modified: trunk/sampledoc_tut/conf.py =================================================================== --- trunk/sampledoc_tut/conf.py 2009-08-11 12:08:25 UTC (rev 7469) +++ trunk/sampledoc_tut/conf.py 2009-08-11 12:29:52 UTC (rev 7470) @@ -46,7 +46,7 @@ # General information about the project. project = u'sampledoc' -copyright = u'2009, jdh' +copyright = u'2009, John Hunter, Fernando Perez, Michael Droettboom' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -181,7 +181,7 @@ # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'sampledoc.tex', u'sampledoc Documentation', - u'jdh', 'manual'), + u'John Hunter, Fernando Perez, Michael Droettboom', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of Modified: trunk/sampledoc_tut/getting_started.rst =================================================================== --- trunk/sampledoc_tut/getting_started.rst 2009-08-11 12:08:25 UTC (rev 7469) +++ trunk/sampledoc_tut/getting_started.rst 2009-08-11 12:29:52 UTC (rev 7470) @@ -37,7 +37,7 @@ make html If you now point your browser to :file:`_build/html/index.html`, you -should see a basic spinx site. +should see a basic sphinx site. .. image:: _static/basic_screenshot.png @@ -61,9 +61,8 @@ home:~/tmp/sampledoc> pwd /Users/jdhunter/tmp/sampledoc home:~/tmp/sampledoc> cd .. - home:~/tmp> svn co - https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/\ - sampledoc_tut + home:~/tmp> svn co https://matplotlib.svn.sourceforge.net/svnroot/\ + matplotlib/trunk/sampledoc_tut A sampledoc_tut/cheatsheet.rst A sampledoc_tut/_static A sampledoc_tut/_static/basic_screenshot.png @@ -75,7 +74,8 @@ A sampledoc_tut/index.rst Checked out revision 7449. home:~/tmp> cp sampledoc_tut/getting_started.rst sampledoc/ - home:~/tmp> cp sampledoc_tut/_static/basic_screenshot.png sampledoc/_static/ + home:~/tmp> cp sampledoc_tut/_static/basic_screenshot.png \ + sampledoc/_static/ Now we are ready to rebuild the docs. We used the image directory to include to the screenshot above with:: Modified: trunk/sampledoc_tut/index.rst =================================================================== --- trunk/sampledoc_tut/index.rst 2009-08-11 12:08:25 UTC (rev 7469) +++ trunk/sampledoc_tut/index.rst 2009-08-11 12:29:52 UTC (rev 7470) @@ -11,10 +11,12 @@ installing sphinx, to customizing the look and feel, to using custom extensions for embedding plots, inheritance diagrams, syntax highlighted ipython sessions and more. If you follow along the -tutorial, you'll start with nothing and end up with this site! The -source code for this tutorial lives in mpl svn (see -:ref:`fetching-the-data`) +tutorial, you'll start with nothing and end up with this site -- it's +the bootstrapping documentation tutorial that writes itself! +The source code for this tutorial lives in mpl svn (see +:ref:`fetching-the-data`) and the `sampledoc PDF <sampledoc.pdf>`_ + Contents: .. toctree:: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-08-11 12:41:16
|
Revision: 7471 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7471&view=rev Author: jdh2358 Date: 2009-08-11 12:41:05 +0000 (Tue, 11 Aug 2009) Log Message: ----------- a few fixes from proofreading Modified Paths: -------------- trunk/sampledoc_tut/custom_look.rst trunk/sampledoc_tut/getting_started.rst Modified: trunk/sampledoc_tut/custom_look.rst =================================================================== --- trunk/sampledoc_tut/custom_look.rst 2009-08-11 12:29:52 UTC (rev 7470) +++ trunk/sampledoc_tut/custom_look.rst 2009-08-11 12:41:05 UTC (rev 7471) @@ -6,8 +6,8 @@ ****************************************** The `sphinx <http://sphinx.pocoo.org/>`_ site itself looks better than -the sites created with the default css, so here we'll invoke Tufte's -phrase "Intelligence imitates but genious steals and grab their css +the sites created with the default css, so here we'll invoke TS Elliots' +maxim "Talen imitates, but genius steals" and grab their css and part of their layout. As before, you can either get the required files :file:`_static/default.css`, :file:`_templates:layout.html` and :file:`_static\logo.png` from the website or svn (see Modified: trunk/sampledoc_tut/getting_started.rst =================================================================== --- trunk/sampledoc_tut/getting_started.rst 2009-08-11 12:29:52 UTC (rev 7470) +++ trunk/sampledoc_tut/getting_started.rst 2009-08-11 12:41:05 UTC (rev 7471) @@ -77,11 +77,6 @@ home:~/tmp> cp sampledoc_tut/_static/basic_screenshot.png \ sampledoc/_static/ -Now we are ready to rebuild the docs. We used the image directory to -include to the screenshot above with:: - - .. image:: _static/basic_screenshot.png - The last step is to modify :file:`index.rst` to include the getting_started file (be careful with the indentation, the "getting_started" should line up with the ':' in ``:maxdepth``:: @@ -93,11 +88,23 @@ getting_started.rst -and then rebuild the docs with ``make html``. When you reload the -page, you should see a link to the "Getting Started" docs, and in -there this page with the screenshot. `Voila!` +and then rebuild the docs:: + cd sampledoc + make html + +When you reload the page by refreshing your browser pointing to +:file:`_build/html/index.html`, you should see a link to the +"Getting Started" docs, and in there this page with the screenshot. +`Voila!` + +Note we used the image directive to include to the screenshot above +with:: + + .. image:: _static/basic_screenshot.png + + Next we'll customize the look and feel of our site to give it a logo, some custom css, and update the navigation panels to look more like the `sphinx <http://sphinx.pocoo.org/>`_ site itself -- see This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-08-11 19:28:15
|
Revision: 7473 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7473&view=rev Author: jdh2358 Date: 2009-08-11 19:28:09 +0000 (Tue, 11 Aug 2009) Log Message: ----------- add some links Modified Paths: -------------- trunk/sampledoc_tut/custom_look.rst trunk/sampledoc_tut/extensions.rst trunk/sampledoc_tut/getting_started.rst trunk/sampledoc_tut/index.rst Modified: trunk/sampledoc_tut/custom_look.rst =================================================================== --- trunk/sampledoc_tut/custom_look.rst 2009-08-11 18:01:00 UTC (rev 7472) +++ trunk/sampledoc_tut/custom_look.rst 2009-08-11 19:28:09 UTC (rev 7473) @@ -1,62 +1,62 @@ -.. _custom_look: - - -****************************************** -Customizing the look and feel of the site -****************************************** - -The `sphinx <http://sphinx.pocoo.org/>`_ site itself looks better than -the sites created with the default css, so here we'll invoke TS Elliots' -maxim "Talen imitates, but genius steals" and grab their css -and part of their layout. As before, you can either get the required -files :file:`_static/default.css`, :file:`_templates:layout.html` and -:file:`_static\logo.png` from the website or svn (see -:ref:`fetching-the-data`). Since I did a svn checkout before, I will -just copy the stuff I need from there:: - - home:~/tmp/sampledoc> cp ../sampledoc_tut/_static/default.css _static/ - home:~/tmp/sampledoc> cp ../sampledoc_tut/_templates/layout.html _templates/ - home:~/tmp/sampledoc> cp ../sampledoc_tut/_static/logo.png _static/ - home:~/tmp/sampledoc> ls _static/ _templates/ - _static/: - basic_screenshot.png default.css logo.png - - _templates/: - layout.html - -Sphinx will automatically pick up the css and layout html files since -we put them in the default places with the default names, but we have -to manually include the logo in our :file:`layout.html`. Let's take a -look at the layout file: the first part puts a horizontal navigation -bar at the top of our page, like you see on the `sphinx -<http://sphinx.pocoo.org>`_ and `matplotlib -<http://matplotlib.sourceforge.net/>`_ sites, the second part includes -a logo that when we click on it will take us `home` and the last part -moves the vertical navigation panels to the right side of the page:: - - {% extends "!layout.html" %} - - - {% block rootrellink %} - <li><a href="{{ pathto('index') }}">home</a>| </li> - <li><a href="{{ pathto('search') }}">search</a>| </li> - <li><a href="{{ pathto('contents') }}">documentation </a> »</li> - {% endblock %} - - - {% block relbar1 %} - - <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> - <a href="{{ pathto('index') }}"><img src="{{ - pathto("_static/logo.png", 1) }}" border="0" alt="sampledoc"/></a> - </div> - {{ super() }} - {% endblock %} - - {# put the sidebar before the body #} - {% block sidebar1 %}{{ sidebar() }}{% endblock %} - {% block sidebar2 %}{% endblock %} - -Once you rebuild the site with a ``make html`` and reload the page in your browser, you should see a fancier site that looks like this - -.. image:: _static/fancy_screenshot.png +.. _custom_look: + + +****************************************** +Customizing the look and feel of the site +****************************************** + +The `sphinx <http://sphinx.pocoo.org/>`_ site itself looks better than +the sites created with the default css, so here we'll invoke TS Elliots' +maxim "Talent imitates, but genius steals" and grab their css +and part of their layout. As before, you can either get the required +files :file:`_static/default.css`, :file:`_templates:layout.html` and +:file:`_static/logo.png` from the website or svn (see +:ref:`fetching-the-data`). Since I did a svn checkout before, I will +just copy the stuff I need from there:: + + home:~/tmp/sampledoc> cp ../sampledoc_tut/_static/default.css _static/ + home:~/tmp/sampledoc> cp ../sampledoc_tut/_templates/layout.html _templates/ + home:~/tmp/sampledoc> cp ../sampledoc_tut/_static/logo.png _static/ + home:~/tmp/sampledoc> ls _static/ _templates/ + _static/: + basic_screenshot.png default.css logo.png + + _templates/: + layout.html + +Sphinx will automatically pick up the css and layout html files since +we put them in the default places with the default names, but we have +to manually include the logo in our :file:`layout.html`. Let's take a +look at the layout file: the first part puts a horizontal navigation +bar at the top of our page, like you see on the `sphinx +<http://sphinx.pocoo.org>`_ and `matplotlib +<http://matplotlib.sourceforge.net/>`_ sites, the second part includes +a logo that when we click on it will take us `home` and the last part +moves the vertical navigation panels to the right side of the page:: + + {% extends "!layout.html" %} + + + {% block rootrellink %} + <li><a href="{{ pathto('index') }}">home</a>| </li> + <li><a href="{{ pathto('search') }}">search</a>| </li> + <li><a href="{{ pathto('contents') }}">documentation </a> »</li> + {% endblock %} + + + {% block relbar1 %} + + <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> + <a href="{{ pathto('index') }}"><img src="{{ + pathto("_static/logo.png", 1) }}" border="0" alt="sampledoc"/></a> + </div> + {{ super() }} + {% endblock %} + + {# put the sidebar before the body #} + {% block sidebar1 %}{{ sidebar() }}{% endblock %} + {% block sidebar2 %}{% endblock %} + +Once you rebuild the site with a ``make html`` and reload the page in your browser, you should see a fancier site that looks like this + +.. image:: _static/fancy_screenshot.png Modified: trunk/sampledoc_tut/extensions.rst =================================================================== --- trunk/sampledoc_tut/extensions.rst 2009-08-11 18:01:00 UTC (rev 7472) +++ trunk/sampledoc_tut/extensions.rst 2009-08-11 19:28:09 UTC (rev 7473) @@ -13,7 +13,7 @@ groups, eg numpy and ipython. We're collecting these in this tutorial and showing you how to install and use them for your own project. First let's grab the python extension files from the :file:`sphinxext` -directory from svn (see :ref:`fetching-the-data`, and install them in +directory from svn (see :ref:`fetching-the-data`), and install them in our :file:`sampledoc` project :file:`sphinxext` directory:: home:~/tmp/sampledoc> mkdir sphinxext @@ -60,9 +60,10 @@ ipython sessions ================ -Michael Droettboom contributed a sphinx extension which does pygments -syntax highlighting on ipython sessions. Just use ipython as the -language in the sourcecode directive:: +Michael Droettboom contributed a sphinx extension which does `pygments +<http://pygments.org>`_ syntax highlighting on `ipython +<http://ipython.scipy.org>`_ sessions. Just use ipython as the +language in the ``sourcecode`` directive:: .. sourcecode:: ipython @@ -135,6 +136,10 @@ All three of these options for math are designed to behave in the same way. +See the matplotlib `mathtext guide +<http://matplotlib.sourceforge.net/users/mathtext.html>`_ for lots +more information on writing mathematical expressions in matplotlib. + .. _pyplots: Inserting matplotlib plots @@ -183,6 +188,10 @@ plt.show() +See the matplotlib `pyplot tutorial +<http://matplotlib.sourceforge.net/users/pyplot_tutorial.html>`_ and +the `gallery <http://matplotlib.sourceforge.net/gallery.html>`_ for +lots of examples of matplotlib plots. Inheritance diagrams ==================== Modified: trunk/sampledoc_tut/getting_started.rst =================================================================== --- trunk/sampledoc_tut/getting_started.rst 2009-08-11 18:01:00 UTC (rev 7472) +++ trunk/sampledoc_tut/getting_started.rst 2009-08-11 19:28:09 UTC (rev 7473) @@ -55,8 +55,9 @@ we'll just grab them one at a time, so you can learn what needs to be changed where. Since we have more files to come, I'm going to grab the whole svn directory and just copy the files I need over for now. -First, I'll cd to the directory containing my project, and get the -"finished" product, and then copy in just the files I need:: +First, I'll cd up back into the directory containing my project, check +out the "finished" product from svn, and then copy in just the files I +need into my :file:`sampledoc` directory:: home:~/tmp/sampledoc> pwd /Users/jdhunter/tmp/sampledoc @@ -78,8 +79,8 @@ sampledoc/_static/ The last step is to modify :file:`index.rst` to include the -getting_started file (be careful with the indentation, the -"getting_started" should line up with the ':' in ``:maxdepth``:: +:file:`getting_started.rst` file (be careful with the indentation, the +"g" in "getting_started" should line up with the ':' in ``:maxdepth``:: Contents: Modified: trunk/sampledoc_tut/index.rst =================================================================== --- trunk/sampledoc_tut/index.rst 2009-08-11 18:01:00 UTC (rev 7472) +++ trunk/sampledoc_tut/index.rst 2009-08-11 19:28:09 UTC (rev 7473) @@ -7,18 +7,17 @@ ================== This is a tutorial introduction to quickly get you up and running with -your own sphinx documentation system. We'll cover everything from -installing sphinx, to customizing the look and feel, to using custom -extensions for embedding plots, inheritance diagrams, syntax -highlighted ipython sessions and more. If you follow along the -tutorial, you'll start with nothing and end up with this site -- it's -the bootstrapping documentation tutorial that writes itself! +your own sphinx documentation system. We'll cover installing sphinx, +customizing the look and feel, using custom extensions for embedding +plots, inheritance diagrams, syntax highlighted ipython sessions and +more. If you follow along the tutorial, you'll start with nothing and +end up with this site -- it's the bootstrapping documentation tutorial +that writes itself! The source code for this tutorial lives in mpl svn (see -:ref:`fetching-the-data`) and the `sampledoc PDF <sampledoc.pdf>`_ +:ref:`fetching-the-data`) and you can grab a harcopy of the the +`sampledoc PDF <sampledoc.pdf>`_ -Contents: - .. toctree:: :maxdepth: 2 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2009-08-21 05:33:33
|
Revision: 7514 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7514&view=rev Author: jdh2358 Date: 2009-08-21 05:33:25 +0000 (Fri, 21 Aug 2009) Log Message: ----------- tweaks to sampledoc Modified Paths: -------------- trunk/sampledoc_tut/custom_look.rst trunk/sampledoc_tut/extensions.rst Modified: trunk/sampledoc_tut/custom_look.rst =================================================================== --- trunk/sampledoc_tut/custom_look.rst 2009-08-20 23:16:11 UTC (rev 7513) +++ trunk/sampledoc_tut/custom_look.rst 2009-08-21 05:33:25 UTC (rev 7514) @@ -9,7 +9,7 @@ the sites created with the default css, so here we'll invoke TS Elliots' maxim "Talent imitates, but genius steals" and grab their css and part of their layout. As before, you can either get the required -files :file:`_static/default.css`, :file:`_templates:layout.html` and +files :file:`_static/default.css`, :file:`_templates/layout.html` and :file:`_static/logo.png` from the website or svn (see :ref:`fetching-the-data`). Since I did a svn checkout before, I will just copy the stuff I need from there:: Modified: trunk/sampledoc_tut/extensions.rst =================================================================== --- trunk/sampledoc_tut/extensions.rst 2009-08-20 23:16:11 UTC (rev 7513) +++ trunk/sampledoc_tut/extensions.rst 2009-08-21 05:33:25 UTC (rev 7514) @@ -26,7 +26,7 @@ In addition to the builtin matplotlib extensions for embedding pyplot plots and rendering math with matplotlib's native math engine, we also have extensions for syntax highlighting ipython sessions, making -inhertiance diagrams, and more. +inhertiance diagrams, and more. We need to inform sphinx of our new extensions in the :file:`conf.py` file by adding the following. First we tell it where to find the extensions:: @@ -37,7 +37,7 @@ sys.path.append(os.path.abspath('sphinxext')) And then we tell it what extensions to load:: - + # Add any Sphinx extension module names here, as strings. They can # be extensions coming with Sphinx (named 'sphinx.ext.*') or your # custom ones. @@ -108,13 +108,13 @@ .. math:: - W^{3\beta}_{\delta_1 \rho_1 \sigma_2} \approx U^{3\beta}_{\delta_1 \rho_1} + W^{3\beta}_{\delta_1 \rho_1 \sigma_2} \approx U^{3\beta}_{\delta_1 \rho_1} -which is rendered as +which is rendered as .. math:: - W^{3\beta}_{\delta_1 \rho_1 \sigma_2} \approx U^{3\beta}_{\delta_1 \rho_1} + W^{3\beta}_{\delta_1 \rho_1 \sigma_2} \approx U^{3\beta}_{\delta_1 \rho_1} This documentation framework includes a Sphinx extension, :file:`sphinxext/mathmpl.py`, that uses matplotlib to render math @@ -147,9 +147,19 @@ Inserting automatically-generated plots is easy. Simply put the script to generate the plot in the :file:`pyplots` directory, and -refer to it using the ``plot`` directive. To include the source code -for the plot in the document, pass the ``include-source`` parameter:: +refer to it using the ``plot`` directive. First make a +:file:`pyplots` directory at the top level of your project (next to +:``conf.py``) and copy the :file:`ellipses.py`` file into it:: + home:~/tmp/sampledoc> mkdir pyplots + home:~/tmp/sampledoc> cp ../sampledoc_tut/pyplots/ellipses.py pyplots/ + + +You can refer to this file in your sphinx documentation; by default it +will just inline the plot with links to the source and PF and high +resolution PNGS. To also include the source code for the plot in the +document, pass the ``include-source`` parameter:: + .. plot:: pyplots/ellipses.py :include-source: @@ -161,9 +171,9 @@ :include-source: -You can also inline simple plots, and the code will be executed at -documentation build time and the figure inserted into your docs; the -following code:: +You can also inline code for plots directly, and the code will be +executed at documentation build time and the figure inserted into your +docs; the following code:: .. plot:: @@ -192,7 +202,7 @@ <http://matplotlib.sourceforge.net/users/pyplot_tutorial.html>`_ and the `gallery <http://matplotlib.sourceforge.net/gallery.html>`_ for lots of examples of matplotlib plots. - + Inheritance diagrams ==================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2010-12-13 15:25:21
|
Revision: 8828 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8828&view=rev Author: jdh2358 Date: 2010-12-13 15:25:15 +0000 (Mon, 13 Dec 2010) Log Message: ----------- added ipython directive tut Modified Paths: -------------- trunk/sampledoc_tut/conf.py trunk/sampledoc_tut/extensions.rst trunk/sampledoc_tut/index.rst Modified: trunk/sampledoc_tut/conf.py =================================================================== --- trunk/sampledoc_tut/conf.py 2010-12-10 18:13:57 UTC (rev 8827) +++ trunk/sampledoc_tut/conf.py 2010-12-13 15:25:15 UTC (rev 8828) @@ -25,6 +25,7 @@ extensions = ['matplotlib.sphinxext.mathmpl', 'matplotlib.sphinxext.only_directives', 'matplotlib.sphinxext.plot_directive', + 'matplotlib.sphinxext.ipython_directive', 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'ipython_console_highlighting', Modified: trunk/sampledoc_tut/extensions.rst =================================================================== --- trunk/sampledoc_tut/extensions.rst 2010-12-10 18:13:57 UTC (rev 8827) +++ trunk/sampledoc_tut/extensions.rst 2010-12-13 15:25:15 UTC (rev 8828) @@ -221,6 +221,11 @@ .. _extensions-literal: + +See the :ref:`ipython_directive` for a tutorial on embedding stateful, +matplotlib aware ipython sessions into your rest docs with multiline +and doctest support. + This file ========= Modified: trunk/sampledoc_tut/index.rst =================================================================== --- trunk/sampledoc_tut/index.rst 2010-12-10 18:13:57 UTC (rev 8827) +++ trunk/sampledoc_tut/index.rst 2010-12-13 15:25:15 UTC (rev 8828) @@ -24,6 +24,7 @@ getting_started.rst custom_look.rst extensions.rst + ipython_directive.rst cheatsheet.rst emacs_help.rst This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2010-12-13 15:52:44
|
Revision: 8832 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8832&view=rev Author: jdh2358 Date: 2010-12-13 15:52:37 +0000 (Mon, 13 Dec 2010) Log Message: ----------- fix broken link on homepage Modified Paths: -------------- trunk/sampledoc_tut/_templates/layout.html trunk/sampledoc_tut/extensions.rst trunk/sampledoc_tut/getting_started.rst trunk/sampledoc_tut/ipython_directive.rst Modified: trunk/sampledoc_tut/_templates/layout.html =================================================================== --- trunk/sampledoc_tut/_templates/layout.html 2010-12-13 15:51:13 UTC (rev 8831) +++ trunk/sampledoc_tut/_templates/layout.html 2010-12-13 15:52:37 UTC (rev 8832) @@ -4,7 +4,6 @@ {% block rootrellink %} <li><a href="{{ pathto('index') }}">home</a>| </li> <li><a href="{{ pathto('search') }}">search</a>| </li> - <li><a href="{{ pathto('contents') }}">documentation </a> »</li> {% endblock %} Modified: trunk/sampledoc_tut/extensions.rst =================================================================== --- trunk/sampledoc_tut/extensions.rst 2010-12-13 15:51:13 UTC (rev 8831) +++ trunk/sampledoc_tut/extensions.rst 2010-12-13 15:52:37 UTC (rev 8832) @@ -1,6 +1,6 @@ .. _extensions: +< - **************************************************** Sphinx extensions for embedded plots, math and more **************************************************** @@ -19,9 +19,8 @@ home:~/tmp/sampledoc> mkdir sphinxext home:~/tmp/sampledoc> cp ../sampledoc_tut/sphinxext/*.py sphinxext/ home:~/tmp/sampledoc> ls sphinxext/ - apigen.py inheritance_diagram.py - docscrape.py ipython_console_highlighting.py - docscrape_sphinx.py numpydoc.py + apigen.py docscrape_sphinx.py ipython_console_highlighting.py + docscrape.py inheritance_diagram.py numpydoc.py In addition to the builtin matplotlib extensions for embedding pyplot plots and rendering math with matplotlib's native math engine, we also @@ -41,16 +40,17 @@ # Add any Sphinx extension module names here, as strings. They can # be extensions coming with Sphinx (named 'sphinx.ext.*') or your # custom ones. - extensions = ['matplotlib.sphinxext.mathmpl', + extensions = [ + 'matplotlib.sphinxext.mathmpl', 'matplotlib.sphinxext.only_directives', 'matplotlib.sphinxext.plot_directive', + 'matplotlib.sphinxext.ipython_directive', 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'ipython_console_highlighting', 'inheritance_diagram', 'numpydoc'] - Now let's look at some of these in action. You can see the literal source for this file at :ref:`extensions-literal`. Modified: trunk/sampledoc_tut/getting_started.rst =================================================================== --- trunk/sampledoc_tut/getting_started.rst 2010-12-13 15:51:13 UTC (rev 8831) +++ trunk/sampledoc_tut/getting_started.rst 2010-12-13 15:52:37 UTC (rev 8832) @@ -1,113 +1,113 @@ -.. _getting_started: - - -*************** -Getting started -*************** - -.. _installing-docdir: - -Installing your doc directory -============================= - -You may already have sphinx `sphinx <http://sphinx.pocoo.org/>`_ -installed -- you can check by doing:: - - python -c 'import sphinx' - -If that fails grab the latest version of and install it with:: - - > sudo easy_install sphinx - -Now you are ready to build a template for your docs, using -sphinx-quickstart:: - - > sphinx-quickstart - -accepting most of the defaults. I choose "sampledoc" as the name of my -project. cd into your new directory and check the contents:: - - home:~/tmp/sampledoc> ls - Makefile _static conf.py - _build _templates index.rst - -The index.rst is the master ReST for your project, but before adding -anything, let's see if we can build some html:: - - make html - -If you now point your browser to :file:`_build/html/index.html`, you -should see a basic sphinx site. - -.. image:: _static/basic_screenshot.png - -.. _fetching-the-data: - -Fetching the data ------------------ - -Now we will start to customize out docs. Grab a couple of files from -the `web site -<http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/sampledoc_tut/>`_ -or svn. You will need :file:`getting_started.rst` and -:file:`_static/basic_screenshot.png`. All of the files live in the -"completed" version of this tutorial, but since this is a tutorial, -we'll just grab them one at a time, so you can learn what needs to be -changed where. Since we have more files to come, I'm going to grab -the whole svn directory and just copy the files I need over for now. -First, I'll cd up back into the directory containing my project, check -out the "finished" product from svn, and then copy in just the files I -need into my :file:`sampledoc` directory:: - - home:~/tmp/sampledoc> pwd - /Users/jdhunter/tmp/sampledoc - home:~/tmp/sampledoc> cd .. - home:~/tmp> svn co https://matplotlib.svn.sourceforge.net/svnroot/\ - matplotlib/trunk/sampledoc_tut - A sampledoc_tut/cheatsheet.rst - A sampledoc_tut/_static - A sampledoc_tut/_static/basic_screenshot.png - A sampledoc_tut/conf.py - A sampledoc_tut/Makefile - A sampledoc_tut/_templates - A sampledoc_tut/_build - A sampledoc_tut/getting_started.rst - A sampledoc_tut/index.rst - Checked out revision 7449. - home:~/tmp> cp sampledoc_tut/getting_started.rst sampledoc/ - home:~/tmp> cp sampledoc_tut/_static/basic_screenshot.png \ - sampledoc/_static/ - -The last step is to modify :file:`index.rst` to include the -:file:`getting_started.rst` file (be careful with the indentation, the -"g" in "getting_started" should line up with the ':' in ``:maxdepth``:: - - Contents: - - .. toctree:: - :maxdepth: 2 - - getting_started.rst - -and then rebuild the docs:: - - cd sampledoc - make html - - -When you reload the page by refreshing your browser pointing to -:file:`_build/html/index.html`, you should see a link to the -"Getting Started" docs, and in there this page with the screenshot. -`Voila!` - -Note we used the image directive to include to the screenshot above -with:: - - .. image:: _static/basic_screenshot.png - - -Next we'll customize the look and feel of our site to give it a logo, -some custom css, and update the navigation panels to look more like -the `sphinx <http://sphinx.pocoo.org/>`_ site itself -- see -:ref:`custom_look`. - +.. _getting_started: + + +*************** +Getting started +*************** + +.. _installing-docdir: + +Installing your doc directory +============================= + +You may already have sphinx `sphinx <http://sphinx.pocoo.org/>`_ +installed -- you can check by doing:: + + python -c 'import sphinx' + +If that fails grab the latest version of and install it with:: + + > sudo easy_install -U Sphinx + +Now you are ready to build a template for your docs, using +sphinx-quickstart:: + + > sphinx-quickstart + +accepting most of the defaults. I choose "sampledoc" as the name of my +project. cd into your new directory and check the contents:: + + home:~/tmp/sampledoc> ls + Makefile _static conf.py + _build _templates index.rst + +The index.rst is the master ReST for your project, but before adding +anything, let's see if we can build some html:: + + make html + +If you now point your browser to :file:`_build/html/index.html`, you +should see a basic sphinx site. + +.. image:: _static/basic_screenshot.png + +.. _fetching-the-data: + +Fetching the data +----------------- + +Now we will start to customize out docs. Grab a couple of files from +the `web site +<http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/sampledoc_tut/>`_ +or svn. You will need :file:`getting_started.rst` and +:file:`_static/basic_screenshot.png`. All of the files live in the +"completed" version of this tutorial, but since this is a tutorial, +we'll just grab them one at a time, so you can learn what needs to be +changed where. Since we have more files to come, I'm going to grab +the whole svn directory and just copy the files I need over for now. +First, I'll cd up back into the directory containing my project, check +out the "finished" product from svn, and then copy in just the files I +need into my :file:`sampledoc` directory:: + + home:~/tmp/sampledoc> pwd + /Users/jdhunter/tmp/sampledoc + home:~/tmp/sampledoc> cd .. + home:~/tmp> svn co https://matplotlib.svn.sourceforge.net/svnroot/\ + matplotlib/trunk/sampledoc_tut + A sampledoc_tut/cheatsheet.rst + A sampledoc_tut/_static + A sampledoc_tut/_static/basic_screenshot.png + A sampledoc_tut/conf.py + A sampledoc_tut/Makefile + A sampledoc_tut/_templates + A sampledoc_tut/_build + A sampledoc_tut/getting_started.rst + A sampledoc_tut/index.rst + Checked out revision 7449. + home:~/tmp> cp sampledoc_tut/getting_started.rst sampledoc/ + home:~/tmp> cp sampledoc_tut/_static/basic_screenshot.png \ + sampledoc/_static/ + +The last step is to modify :file:`index.rst` to include the +:file:`getting_started.rst` file (be careful with the indentation, the +"g" in "getting_started" should line up with the ':' in ``:maxdepth``:: + + Contents: + + .. toctree:: + :maxdepth: 2 + + getting_started.rst + +and then rebuild the docs:: + + cd sampledoc + make html + + +When you reload the page by refreshing your browser pointing to +:file:`_build/html/index.html`, you should see a link to the +"Getting Started" docs, and in there this page with the screenshot. +`Voila!` + +Note we used the image directive to include to the screenshot above +with:: + + .. image:: _static/basic_screenshot.png + + +Next we'll customize the look and feel of our site to give it a logo, +some custom css, and update the navigation panels to look more like +the `sphinx <http://sphinx.pocoo.org/>`_ site itself -- see +:ref:`custom_look`. + Modified: trunk/sampledoc_tut/ipython_directive.rst =================================================================== --- trunk/sampledoc_tut/ipython_directive.rst 2010-12-13 15:51:13 UTC (rev 8831) +++ trunk/sampledoc_tut/ipython_directive.rst 2010-12-13 15:52:37 UTC (rev 8832) @@ -9,8 +9,17 @@ extracts the input and output lines. These prompts will be renumbered starting at ``1``. The inputs will be fed to an embedded ipython interpreter and the outputs from that interpreter will be inserted as -well. +well. For example, code blocks like the following:: + .. ipython:: + + In [136]: x = 2 + + In [137]: x**3 + Out[137]: 8 + +will be rendered as + .. ipython:: In [136]: x = 2 @@ -18,6 +27,16 @@ In [137]: x**3 Out[137]: 8 +.. note:: + + This tutorial should be read side-by-side with the Sphinc source + for this document (see :ref:`ipython_literal`) because otherwise + you will see only the rendered output and not the code that + generated it. Excepting the example above, we will not in general + be showing the liuteral rest in this document that generates the + rendered output. + + The state from previous sessions is stored, and standard error is trapped. At doc build time, ipython's output and std err will be inserted, and prompts will be renumbered. So the prompt below should @@ -261,4 +280,10 @@ match. Also, can be applied to the entire ``..ipython`` block as a directive option with ``:doctest:``. -That's all folks! +.. _ipython_literal: + +Sphinx source for this tutorial +==================================== + +.. literalinclude:: ipython_directive.rst + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |