Skip to content

Instantly share code, notes, and snippets.

@phaustin
Last active February 1, 2016 03:06
Show Gist options
  • Select an option

  • Save phaustin/a7a2a54fdcd3b9569c89 to your computer and use it in GitHub Desktop.

Select an option

Save phaustin/a7a2a54fdcd3b9569c89 to your computer and use it in GitHub Desktop.
Readme_sphinx.org

to get started run sphinx_quickstart from and xterm

http://matplotlib.sourceforge.net/sampledoc/

””” Uses three different methods to interpolate the function :math:`f(x)=\sqrt{1 + |x|}`

Parameters


pn : integer number of points in f(x)

Returns


(x,y) : (array,array) tupple (x(pn) , y(pn)) with analytic values y=f(x) in the range :math:`-5 < x < 5`

plot is produced as a side effect, with three lines of x=101 points showing the analytic function, linear interpolation and cubic spline interpolation “””

.. highlight:: python

.. code-block:: python

””” integrate and interpolate the hydrostatic equation for a particular atmospheric sounding “””

from scipy.integrate.quadrature import cumtrapz import numpy as np import scipy.interpolate as interp from matplotlib.cbook import iterable

class hydrostat(object): “”” temp (K), press (Pa) “”” def __init__(self,temp,press,qv,height=None): self.temp=temp self.press=press self.height=height self.qv=qv self.Rd=287. self.g=9.8

cross referencing


refs.txt contains

.. _Software carpentry git tutorial: http://www.software-carpentry.org/v5/novice/git/

file starts with:

.. include:: refs.txt

refereced with

`Software carpentry git tutorial`_

http://docutils.sourceforge.net/docs/user/rst/quickref.html#external-hyperlink-targets

.. _Volume expansion table: http://physics.info/expansion/

`Volume expansion table`_

`volume expansion table`_

have had some problems with undersocres in tags

.. _schroeder: Schroeder _________

in one file

referenced by

  • zerox copy of :ref:`schroeder`

which makes the link:

http://clouds.eos.ubc.ca/~phil/thesis/index.html#schroeder

this works:

.. _level-one:

Level one =========

.. _level-two:

Level two +++++++++

.. _level-three:

Level three


.. _level-four:

Level four __________

:ref:`level-one`

:ref:`level-two`

:ref:`level-three`

:ref:`level-four`

see also https://github.com/lddubeau/rst-on-github/blob/master/README.rst for github issues

in link_names.txt

.. _Bohren Monte Carlo: http://clouds.eos.ubc.ca/~phil/courses/eosc582/private/bohren_excerpts1.pdf

referenced with

`Bohren Monte Carlo`_

substitutions


.. |CO2| replace:: CO\ :sub:`2`\

.. |wm2| replace:: Watts/meter\ :sup:`2`\

CO2absorption

putting outside links in table of contents


.. toctree::

Course objectives <learning_goals>

Text chapters <text>

Matlab resources http://clouds.eos.ubc.ca/~phil/numeric/docs/_build/html/matlab.html

Thermo code <thermo>

Blank Tephigram http://clouds.eos.ubc.ca/~phil/courses/atsc405/wh_skewT.pdf

hidden entries


.. toctree::

<problems>

verbatim code snippets


put code after this::

or

  • don’t copy the hdf file, it’s 142 Mbytes. Just do a symbolic link on swift to get it in your working directory like this:

    .. literalinclude:: try_include.txt

math mode


  • What is a weighting function? Why is it maximum when :math:`τ=1`

.. math::

α= β^2 ∫_0^∞ dt

watch indent level

jinja2


making tables


<file:///~/public_html/readmes/Readme_python.nm#* constructing tables from dicts>

images


.. image:: 1-ie-2.jpg

including notebooks in sphinx

.. notebook:: TransferFunctionHelper_Tutorial.ipynb

https://bitbucket.org/ngoldbaum/yt-mattfork/src/1923fae835fe1d1bf8145c46b6062ca9e9523f44/doc/extensions/notebook_sphinxext.py?at=yt-3.0

git docs workflow

http://daler.github.io/sphinxdoc-test/includeme.html#general-workflow

https://gist.github.com/brantfaircloth/791759

http://dont-be-afraid-to-commit.readthedocs.org/en/latest/documentation.html

relative path names in index.rst

http://daler.github.io/sphinxdoc-test/includeme.html#index-rst-changes

Make a new file, sphinxdoc-test/docs/source/includeme.rst. In there, put an include directive pointing to the true“README.rst“. So includeme.rst should look like this:

.. include:: ../../README.rst

Then in index.rst, add includeme to the toctree. So the relevant part of index.rst should look something like:

.. toctree::

includeme

now is the time

using rst2pdf

airwatch/Personal%20Content/EOSC%20340%20Fall%202015%20Grades%20(Ivanochko,%20Tara)/midterm_1/rst2pdf.sty

rst2pdf –print-stylesheet

test=”Crompton Jeffrey\nDONG WENJING\nHurley David\nIzett Robert\nJarnikova Tereza\nLiu Jie\nMachuca Idalia\nPeterson Georgia\nThibault Jacquie-Lee\nVanderWees Jesse\nYu Xiaoxin\n \nEverard Kelsey\nJansens Bryan\n \nAtkinson Tim\nChui Timothy\nFung Matthew\nYuen Sang\nHirschi Jonathon\nMonillas Ronald James\nThompson Hadleigh”

with open(‘out.rst’,’w’) as f: for item in test.split(‘\n’): try: last,first=item.split() f.write(‘.. raw:: pdf\n’) f.write(‘\n PageBreak\n\n’) name=’{} {}’.format(first,last) f.write(‘{}\n’.format(name)) plusses=’+’*len(name) f.write(‘{}\n\n’.format(plusses)) except: pass

for my theme

pip install sphinx-bootstrap-theme pip install -e sphinxcontrib-fulltoc pip install -e phil-bootstraph-theme

find all functions in a module for autodoc

#http://stackoverflow.com/questions/139180/listing-all-functions-in-a-python-module

~/repos/pythonlibs/pyutils/list_functions.py

import importlib,sys from inspect import getmembers, isfunction, getmodule name=sys.argv[1] importlib.import_module(name, package=None) module=sys.modules[name] the_funcs = getmembers(module, isfunction) for item in the_funcs: try_module=getmodule(item[1]) if try_module == module: print(item[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment