forked from statsmodels/statsmodels
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'doc_devel'. Closes statsmodels#478.
* doc_devel: DOC: Cherry picked most of Josefs recent cleanups DOC: dev/git_notes.rst minor edits DOC: datasets DOC: simplify dev/examples.rst DOC: package_overview content split and sent to relevant files DOC: more precise patch submission process DOC: pitfalls.rst reorg DOC: importpaths.rst reorg
- Loading branch information
Showing
10 changed files
with
412 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,43 @@ | ||
.. _examples: | ||
|
||
Statsmodels Examples | ||
==================== | ||
Examples | ||
======== | ||
|
||
Examples go in the top-level examples directory. Let's try to have documentation | ||
and tutorials for as many models and code uses as possible! These are invaluable | ||
for new users to get up and running. These can also be Cookbook recipes, but there is no wiki yet. For the most part these are just runnable example scripts. However, when the documentation is built, these are converted into ReST files and included in the documentation. There is a bit of magic that can be used to make these look nice. | ||
Examples are invaluable for new users who hope to get up and running quickly | ||
with `statsmodels`, and they are extremely useful to those who wish to explore | ||
new features of `statsmodels`. We hope to provide documentation and tutorials | ||
for as many models and use-cases as possible! | ||
|
||
reStructured Text | ||
~~~~~~~~~~~~~~~~~ | ||
Most user-contributed examples/tutorials/recipes should be placed on the | ||
`statsmodels examples wiki page | ||
<https://github.com/statsmodels/statsmodels/wiki/Examples:-user-contributions>`_ | ||
That wiki page is freely editable. Please post your cool tricks, | ||
examples, and recipes on there! | ||
|
||
Every example file must have a module level docstring. This docstring should contain the tile of the example, and that's it. You can include ReST markup in the files as comments. Anything that is commented out will be rendered as ReST with a few exceptions noted below. If you want a true comment in the outputed file, then you should use ``#..``. The hash symbol is stripped leaving ``..``, ReST markup for a comment line. | ||
If you would rather have your example file officially accepted to the | ||
`statsmodels` distribution and posted on this website, you will need to go | ||
through the normal `patch submission process <index.html#submitting-a-patch>`_. | ||
|
||
Code Snippets | ||
~~~~~~~~~~~~~ | ||
File Format | ||
~~~~~~~~~~~ | ||
|
||
Code snippets are rendered using the :ref:`ipython_directive` for Sphinx. See | ||
the documentation for explaining its usage in greater detail. Some of it is | ||
explained in :ref:`special_markup`. | ||
Examples are simple runnable python scripts that go in the top-level examples | ||
directory. We use the `ipython_directive for Sphinx | ||
<http://ipython.org/ipython-doc/dev/development/ipython_directive.html>`_ to | ||
convert them automatically to `reStructuredText | ||
<http://docutils.sourceforge.net/rst.html>`_ and html at build time. | ||
|
||
.. _special_markup: | ||
Each line of the script is executed; both the python code and the printed | ||
results are shown in the output file. Lines that are commented out using the | ||
hash symbol ``#`` are rendered as reST markup. | ||
|
||
Special Markup | ||
~~~~~~~~~~~~~~ | ||
**Comments**: "True" comments that should not appear in the output file should be written on lines that start with ``#..``. | ||
|
||
**Error handling**: Syntax errors in pure Python will raise an error during the build process. If you need to show a SyntaxError, an alternative would be to provide a verbatim copy of an IPython session encased in a ReST code block instead of pure Python code. | ||
|
||
**Suppressing lines**: To suppress a line in the built documentation, follow it with a semicolon. | ||
|
||
**Figures**: To save a figure, prepend the line directly before the plotting command with ``#@savefig file_name.png width=4in``, for example. You do not need to call show or close. | ||
|
||
**IPython magics**: You can use IPython magics by writing a line like this: ``#%timeit X = np.empty((1000,1000))``. | ||
|
||
Pretty much anything you can do with the IPython directive is supported for the example scripts. The only thing that is not well supported is error handling of SyntaxErrors. Syntax errors in pure Python will raise an error during the build process. You could provide an IPython session instead of pure Python if you want to show a SyntaxError for some reason. Other than this, to suppress a line in the built documentation, follow it with a semicolon. To save a figure, prepend the line directly before the plotting command with ``#@savefig file_name.png width=4in``, for example. You don't need to call show or close. You can also call IPython magic functions. So if you wanted to include some timings you could have a line ``#%timeit X = np.empty((1000,1000))``. |
Oops, something went wrong.