doc_guide.rst 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. .. _rst_tutorial:
  2. ###################
  3. Documentation Guide
  4. ###################
  5. This page shows an nice overview of the reStructuredText syntax. This is not a comprehensive list of everything you can do, but should be enough to get you up and running to contribute some really nice documentation. It is based on resources found at `Sphinx <http://sphinx-doc.org/rest.html>`_ .
  6. To get your own local documentation repository running, simply
  7. Introduction
  8. #############
  9. The reStructuredText (RST) syntax provides an easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and parser system. However, you need to be very precise and stick to some strict rules:
  10. * like Python, RST syntax is sensitive to indentation !
  11. * RST requires blank lines between paragraphs
  12. This entire document is written with the RST syntax. In the right sidebar, you should find a link **"Edit on Github"**, which will show each page in reStructuredText raw text format.
  13. .. contents::
  14. :depth: 3
  15. Getting Started
  16. ###############
  17. Getting Git Right
  18. ==================
  19. Learn Git in 15 Minutes `Git Tutorial`_ that will help you get started if you prefer. There is also awesome Git Tutorials on the `Atlassian Git site`_. Here is the link on installing Git if you don't have it yet `Git Install`_
  20. Setting up the Docs Locally
  21. ===============================
  22. One of the great things about Git and documentation is that all people who contribute are encouraged to setup their own local copy of the docs for off-line editing. This by default will ensure that many backups of the documents exist and there is never any concern about losing them.
  23. Assuming you have Python_ already, install Sphinx locally::
  24. $ pip install sphinx sphinx-autobuild
  25. Clone the FusionPBX Github documentation repository::
  26. $ cd /path/to/where_you_want_the_docs
  27. $ git clone https://github.com/fusionpbx/fusionpbx-docs.git
  28. $ cd fusionpbx-docs
  29. Edit files or add new ones then build your changes::
  30. $ make html
  31. Open index.html with your web browser and check your changes::
  32. fusionpbx-docs/build/html/index.html
  33. Edit your files and rebuild until you like what you see, then commit your changes and push to the public repository. Assuming the file you changed is called myfile.rst::
  34. $ git add myfile.rst
  35. $ git commit -m 'your commit message'
  36. $ git push -u origin master
  37. Text Formatting
  38. #################
  39. Inline markup and special characters (e.g., bold, italic, verbatim)
  40. ====================================================================
  41. There are a few special characters used to format text. The special character ``*`` is used to defined bold and italic text as shown in the table below. The backquote character ````` is another special character used to create links to internal or external web pages as you will see in section `Internal and External Links`_.
  42. =========== ================================== ==============================
  43. usage syntax HTML rendering
  44. =========== ================================== ==============================
  45. italic `*italic*` *italic*
  46. bold `**bold**` **bold**
  47. link ```python <www.python.org>`__`` `python <www.python.org>`__
  48. verbatim ````*```` ``*``
  49. =========== ================================== ==============================
  50. The double backquote is used to enter in verbatim mode, which can be used as the escaping character.
  51. There are some restrictions about the ``*`` and `````` syntax. They
  52. * cannot not be nested,
  53. * content may not start or end with whitespace: ``* text*`` is wrong,
  54. * it must be separated from surrounding text by non-word characters like a space.
  55. The use of backslash is a work around to second previous restrictions about whitespaces in the following case:
  56. * ``this is a *longish* paragraph`` is correct and gives *longish*.
  57. * ``this is a long*ish* paragraph`` is not interpreted as expected. You
  58. should use ``this is a long\ *ish* paragraph`` to obtain long\ *ish* paragraph
  59. In Python docstrings it will be necessary to escape any backslash characters so that they actually reach reStructuredText. The simplest way to do this is to use raw strings by adding the letter ``r`` in front of the docstring.
  60. ===================================== ================================
  61. Python string Typical result
  62. ===================================== ================================
  63. ``r"""\*escape* \`with` "\\""""`` ``*escape* `with` "\"``
  64. ``"""\\*escape* \\`with` "\\\\""""`` ``*escape* `with` "\"``
  65. ``"""\*escape* \`with` "\\""""`` ``escape with ""``
  66. ===================================== ================================
  67. Headings
  68. ==========
  69. In order to write a title, you can either underline it or under and overline it. The following examples are correct titles.
  70. .. code-block:: rest
  71. *****
  72. Title
  73. *****
  74. subtitle
  75. ########
  76. subsubtitle
  77. **********************
  78. and so on
  79. Two rules:
  80. * If under and overline are used, their length must be identical
  81. * The length of the underline must be at least as long as the title itself
  82. Normally, there are no heading levels assigned to certain characters as the
  83. structure is determined from the succession of headings. However, it is better to stick to the same convention throughout a project. For instance:
  84. * `#` with overline, for parts
  85. * `*` with overline, for chapters
  86. * `=`, for sections
  87. * `-`, for subsections
  88. * `^`, for subsubsections
  89. * `"`, for paragraphs
  90. Internal and External Links
  91. =============================
  92. In Sphinx, you have 3 type of links:
  93. #. External links (http-like)
  94. #. Implicit links to title
  95. #. Explicit links to user-defined label (e.g., to refer to external titles).
  96. External links
  97. ----------------
  98. If you want to create a link to a website, the syntax is ::
  99. `<http://www.python.org/>`_
  100. which appear as `<http://www.python.org/>`_ . Note the underscore after the final single quote. Since the full name of the link is not always simple or meaningful, you can specify a label (note the space between the label and link name)::
  101. `Python <http://www.python.org/>`_
  102. The rendering is now: `Python <http://www.python.org/>`_.
  103. .. note:: If you have an underscore within the label/name, you got to escape it with a '\\' character.
  104. .. _implicit:
  105. Implicit Links to Titles
  106. ------------------------------
  107. All titles are considered as hyperlinks. A link to a title is just its name within quotes and a final underscore::
  108. `Internal and External links`_
  109. This syntax works only if the title and link are within the same RST file.
  110. If this is not the case, then you need to create a label before the title and refer to this new link explicitly, as explained in `Explicit Links`_ section.
  111. Explicit Links
  112. --------------------
  113. You can create explicit links within your RST files. For instance, this document has a label at the top called ``rst_tutorial``, which is specified by typing::
  114. .. _rst_tutorial:
  115. You can refer to this label using two different methods. The first one is::
  116. rst_tutorial_
  117. The second method use the ``ref`` role as follows::
  118. :ref:`rst_tutorial`
  119. With the first method, the link appears as rst_tutorial_, whereas the second method use the first title's name found after the link. Here, the second method would appear as :ref:`rst_tutorial`.
  120. .. note:: Note that if you use the ``ref`` role, the final underscore is not required anymore.
  121. List and bullets
  122. ================
  123. The following code::
  124. * This is a bulleted list.
  125. * It has two items, the second
  126. item uses two lines. (note the indentation)
  127. 1. This is a numbered list.
  128. 2. It has two items too.
  129. #. This is a numbered list.
  130. #. It has two items too.
  131. gives:
  132. * This is a bulleted list.
  133. * It has two items, the second
  134. item uses two lines. (note the indentation)
  135. 1. This is a numbered list.
  136. 2. It has two items too.
  137. #. This is a numbered list.
  138. #. It has two items too.
  139. .. note:: if two lists are separated by a blanck line only, then the two lists are not differentiated as you can see above.
  140. What are directives
  141. ############################
  142. Sphinx and the RST syntax provides directives to include formatted text. As an example, let us consider the **code-block** syntax. It allows to insert code (here HTML) within your document::
  143. .. code-block:: html
  144. :linenos:
  145. <h1>code block example</h1>
  146. Its rendering is:
  147. .. code-block:: html
  148. :linenos:
  149. <h1>code block example</h1>
  150. Here, **code-block** is the name of the directive. **html** is an argument telling that the code is in HTML format, **lineos** is an option telling to insert line number and finally after a blank line is the text to include.
  151. Note that options are tabulated.
  152. Code and Literal blocks
  153. #######################################
  154. How to include simple code
  155. ===================================
  156. This easiest way to insert literal code blocks is to end a paragraph with the special marker made of a double coulumn `::`. Then, the literal block must be indented::
  157. This is a simple example::
  158. import math
  159. print 'import done'
  160. or::
  161. This is a simple example:
  162. ::
  163. import math
  164. print 'import done'
  165. gives:
  166. This is a simple example::
  167. import math
  168. print 'import done'
  169. code-block directive
  170. ===================================
  171. By default the syntax of the language is Python, but you can specify the language using the **code-block** directive as follows::
  172. .. code-block:: html
  173. :linenos:
  174. <h1>code block example</h1>
  175. produces
  176. .. code-block:: html
  177. :linenos:
  178. <h1>code block example</h1>
  179. Include code with the literalinclude directive
  180. ======================================================
  181. Then, it is also possible to include the contents of a file as follows:
  182. .. code-block:: rest
  183. .. literalinclude:: filename
  184. :linenos:
  185. :language: python
  186. :lines: 1, 3-5
  187. :start-after: 3
  188. :end-before: 5
  189. Tables
  190. ######
  191. There are several ways to write tables. Use standard reStructuredText tables as explained here. They work fine in HTML output, however, there are some gotchas when using tables for LaTeX output.
  192. The rendering of the table depends on the CSS/HTML style, not on sphinx itself.
  193. Simple tables
  194. ================
  195. Simple tables can be written as follows::
  196. +---------+---------+-----------+
  197. | 1 | 2 | 3 |
  198. +---------+---------+-----------+
  199. which gives:
  200. +---------+---------+-----------+
  201. | 1 | 2 | 3 |
  202. +---------+---------+-----------+
  203. Size of the cells can be adjusted as follows::
  204. +---------------------+---------+---+
  205. |1 | 2| 3 |
  206. +---------------------+---------+---+
  207. renders as follows:
  208. +---------------------+---------+---+
  209. |1 | 2| 3 |
  210. +---------------------+---------+---+
  211. This syntax is quite limited, especially for multi cells/columns.
  212. Multicells tables, first method
  213. ====================================
  214. A first method is the following syntax::
  215. +------------+------------+-----------+
  216. | Header 1 | Header 2 | Header 3 |
  217. +============+============+===========+
  218. | body row 1 | column 2 | column 3 |
  219. +------------+------------+-----------+
  220. | body row 2 | Cells may span columns.|
  221. +------------+------------+-----------+
  222. | body row 3 | Cells may | - Cells |
  223. +------------+ span rows. | - contain |
  224. | body row 4 | | - blocks. |
  225. +------------+------------+-----------+
  226. gives:
  227. +------------+------------+-----------+
  228. | Header 1 | Header 2 | Header 3 |
  229. +============+============+===========+
  230. | body row 1 | column 2 | column 3 |
  231. +------------+------------+-----------+
  232. | body row 2 | Cells may span columns.|
  233. +------------+------------+-----------+
  234. | body row 3 | Cells may | - Cells |
  235. +------------+ span rows. | - contain |
  236. | body row 4 | | - blocks. |
  237. +------------+------------+-----------+
  238. Multicells table, second method
  239. ====================================
  240. The previous syntax can be simplified::
  241. ===== ===== ======
  242. Inputs Output
  243. ------------ ------
  244. A B A or B
  245. ===== ===== ======
  246. False False False
  247. True False True
  248. ===== ===== ======
  249. gives:
  250. ===== ===== ======
  251. Inputs Output
  252. ------------ ------
  253. A B A or B
  254. ===== ===== ======
  255. False False False
  256. True False True
  257. ===== ===== ======
  258. .. note:: table and latex documents are not yet compatible in sphinx, and you should therefore precede them with the a special directive (.. htmlonly::)
  259. The tabularcolumns directive
  260. =================================
  261. The previous examples work fine in HTML output, however there are some gotchas when using tables in LaTeX: the column width is hard to determine correctly automatically. For this reason, the following directive exists::
  262. .. tabularcolumns:: column spec
  263. This directive gives a “column spec” for the next table occurring in the source file. It can have values like::
  264. |l|l|l|
  265. which means three left-adjusted (LaTeX syntax). By default, Sphinx uses a table layout with L for every column. This code::
  266. .. tabularcolumns:: |l|c|p{5cm}|
  267. +--------------+---+-----------+
  268. | simple text | 2 | 3 |
  269. +--------------+---+-----------+
  270. gives
  271. .. tabularcolumns:: |l|c|p{5cm}|
  272. +--------------+------------+-----------+
  273. | title | | |
  274. +==============+============+===========+
  275. | simple text | 2 | 3 |
  276. +--------------+------------+-----------+
  277. The csv-table directive
  278. ==========================================
  279. Finally, a convenient way to create table is the usage of CSV-like syntax::
  280. .. csv-table:: a title
  281. :header: "name", "firstname", "age"
  282. :widths: 20, 20, 10
  283. "Smith", "John", 40
  284. "Smith", "John, Junior", 20
  285. that is rendered as follows:
  286. .. csv-table:: a title
  287. :header: "name", "firstname", "age"
  288. :widths: 20, 20, 10
  289. "Smith", "John", 40
  290. "Smith", "John, Junior", 20
  291. The toctree directive
  292. ######################
  293. Sooner or later you will want to structure your project documentation by having several RST files. The **toctree** directive allows you to insert other files within a RST file. The reason to use this directive is that RST does not have facilities to interconnect several documents, or split documents into multiple output files. The **toctree** directive looks like
  294. .. code-block:: rest
  295. .. toctree::
  296. :maxdepth: 2
  297. :numbered:
  298. :titlesonly:
  299. :glob:
  300. :hidden:
  301. intro.rst
  302. chapter1.rst
  303. chapter2.rst
  304. It includes 3 RST files and shows a TOC that includes the title found in the RST documents.
  305. Here are a few notes about the different options
  306. * **maxdepth** is used to indicates the depth of the tree.
  307. * **numbered** adds relevant section numbers.
  308. * **titlesonly** adds only the main title of each document
  309. * **glob** can be used to indicate that * and ? characters are used to indicate patterns.
  310. * **hidden** hides the toctree. It can be used to include files that do not need to be shown (e.g. a bibliography).
  311. The glob option works as follows:
  312. .. code-block:: rest
  313. .. toctree::
  314. :glob:
  315. intro*
  316. recipe/*
  317. *
  318. Note also that the title that appear in the toctree are the file's title. You may want to change this behaviour by changing the toctree as follows:
  319. .. code-block:: rest
  320. .. toctree::
  321. :glob:
  322. Chapter1 description <chapter1>
  323. So that the title of this section is more meaningful.
  324. Images and figures
  325. #######################
  326. Include Images
  327. ===============
  328. Use::
  329. .. image:: _static/images/logo.png
  330. :width: 200px
  331. :align: center
  332. :height: 100px
  333. :alt: alternate text
  334. to put an image
  335. .. image:: _static/images/logo.png
  336. :width: 200px
  337. :align: center
  338. :height: 100px
  339. :alt: alternate text
  340. Include a Figure
  341. =================
  342. ::
  343. .. figure:: _static/images/logo.png
  344. :width: 200px
  345. :align: center
  346. :height: 100px
  347. :alt: alternate text
  348. :figclass: align-center
  349. figure are like images but with a caption
  350. and whatever else youwish to add
  351. .. code-block:: python
  352. import image
  353. gives
  354. .. figure:: _static/images/logo.png
  355. :width: 200px
  356. :align: center
  357. :height: 100px
  358. :alt: alternate text
  359. :figclass: align-center
  360. figure are like images but with a caption
  361. and whatever else youwish to add
  362. .. code-block:: python
  363. import image
  364. The option **figclass** is a CSS class that can be tuned for the final HTML rendering.
  365. Boxes
  366. #################
  367. Colored boxes: note, seealso, todo and warnings
  368. =================================================
  369. There are simple directives like **seealso** that creates nice colored boxes:
  370. .. seealso:: This is a simple **seealso** note.
  371. created using::
  372. .. seealso:: This is a simple **seealso** note.
  373. You have also the **note** directive:
  374. .. note:: This is a **note** box.
  375. with ::
  376. .. note:: This is a **note** box.
  377. and the warning directive:
  378. .. warning:: note the space between the directive and the text
  379. generated with::
  380. .. warning:: note the space between the directive and the text
  381. There is another **todo** directive but requires an extension. See
  382. `Useful extensions`_
  383. Topic directive
  384. ===============
  385. A **Topic** directive allows to write a title and a text together within a box similarly to the **note** directive.
  386. This code::
  387. .. topic:: Your Topic Title
  388. Subsequent indented lines comprise
  389. the body of the topic, and are
  390. interpreted as body elements.
  391. gives
  392. .. topic:: Your Topic Title
  393. Subsequent indented lines comprise
  394. the body of the topic, and are
  395. interpreted as body elements.
  396. Sidebar directive
  397. =================
  398. It is possible to create sidebar using the following code::
  399. .. sidebar:: Sidebar Title
  400. :subtitle: Optional Sidebar Subtitle
  401. Subsequent indented lines comprise
  402. the body of the sidebar, and are
  403. interpreted as body elements.
  404. .. sidebar:: Sidebar Title
  405. :subtitle: Optional Sidebar Subtitle
  406. Subsequent indented lines comprise
  407. the body of the sidebar, and are
  408. interpreted as body elements.
  409. Others
  410. #########
  411. Comments
  412. ====================
  413. Comments can be made by adding two dots at the beginning of a line as follows::
  414. .. comments
  415. Substitutions
  416. ==============
  417. Substitutions are defined as follows::
  418. .. _Python: http://www.python.org/
  419. and to refer to it, use the same syntax as for the internal links: just insert the alias in the text (e.g., ``Python_``, which appears as Python_ ).
  420. A second method is as follows::
  421. .. |longtext| replace:: this is a very very long text to include
  422. and then insert ``|longtext|`` wherever required.
  423. glossary, centered, index, download and field list
  424. =====================================================================
  425. Field list
  426. -----------
  427. :Whatever: this is handy to create new field and the following text is indented
  428. ::
  429. :Whatever: this is handy to create new field
  430. glossary
  431. -----------
  432. ::
  433. .. glossary::
  434. apical
  435. at the top of the plant.
  436. gives
  437. .. glossary::
  438. apical
  439. at the top of the plant.
  440. index
  441. -----
  442. ::
  443. .. index::
  444. download
  445. ---------
  446. ::
  447. :download:`download samplet.py <_downloads/sample.py>`
  448. gives :download:`download sample.py <_downloads/sample.py>`
  449. hlist directive
  450. ------------------
  451. hlist can be use to set a list on several columns.
  452. .. rst:directive:: .. hlist::
  453. ::
  454. .. hlist::
  455. :columns: 3
  456. * first item
  457. * second item
  458. * 3d item
  459. * 4th item
  460. * 5th item
  461. .. hlist::
  462. :columns: 3
  463. * first item
  464. * second item
  465. * 3d item
  466. * 4th item
  467. * 5th item
  468. Footnote
  469. ========
  470. For footnotes, use ``[#name]_`` to mark the footnote location, and add the
  471. footnote body at the bottom of the document after a “Footnotes” rubric
  472. heading, like so::
  473. Some text that requires a footnote [#f1]_ .
  474. .. rubric:: Footnotes
  475. .. [#f1] Text of the first footnote.
  476. You can also explicitly number the footnotes (``[1]_``) or use auto-numbered
  477. footnotes without names (``[#]_``). Here is an example [#footnote1]_.
  478. Citations
  479. =========
  480. Citation references, like [CIT2002]_ may be defined at the bottom of the page::
  481. .. [CIT2002] A citation
  482. (as often used in journals).
  483. and called as follows::
  484. [CIT2002]_
  485. More about aliases
  486. ==================
  487. Directives can be used within aliases::
  488. .. |logo| image:: _static/images/logo.png
  489. :width: 20pt
  490. :height: 20pt
  491. Using this image alias, you can insert it easily in the text `|logo|`, like this |logo|. This is especially useful when dealing with complicated code. For instance, in order to include 2 images within a table do as follows::
  492. +---------+---------+-----------+
  493. | |logo| | |logo| | |longtext||
  494. +---------+---------+-----------+
  495. +---------+---------+-----------+
  496. | |logo| | |logo| | |longtext||
  497. +---------+---------+-----------+
  498. .. note:: Not easy to get exactly what you want though.
  499. Intersphinx
  500. ===============
  501. When you create a project, Sphinx generates a file containing an index to all the possible links (title, classes, functions, ...).
  502. You can refer to those index only if Sphinx knowns where to find this index. THis is possible thanks to the **intersphinx** option in your configuration file.
  503. For instance, Python provides such a file, by default Sphinx knows about it. The following code can be found at the end of a typical Sphinx configuration file. Complete it to your needds::
  504. # Example configuration for intersphinx: refer to the Python standard library.
  505. intersphinx_mapping = {'http://docs.python.org/': None, }
  506. file-wide metadata
  507. ===================
  508. when using the following syntax::
  509. :fieldname: some contents
  510. some special keywords are recognised. For instance, *orphan*, *nocomments*, *tocdepth*.
  511. An example of rendering is the toctree of top of this page.
  512. orphan
  513. -------
  514. Sometimes, you have an rst file, that is not included in any rst files (when using include for instance). Yet, there are warnings. If you want to supprresse the warnings, include this code in the file::
  515. :orphan:
  516. There is also tocdepth and nocomments metadata. See Sphinx homepage.
  517. metainformation
  518. =================
  519. .. rst:directive:: .. sectionauthor:: name <email>
  520. Specifies the author of the current section.::
  521. .. sectionauthor:: John Smith <[email protected]>
  522. By default, this markup isn’t reflected in the output in any way, but you can set the configuration value **show_authors** to True to make them produce a paragraph in the output.
  523. .. rst::directive:: .. codeauthor:: name <email>
  524. Similar to sectionauthor directive
  525. contents directives
  526. ====================
  527. .. rst:directive:: .. contents::
  528. ::
  529. .. contents:: a title for the contents
  530. :depth: 2
  531. * **depth** indicates the max section depth to be shown in the contents
  532. .. ---------------------------------------------------
  533. .. .. _Sphinx: http://sphinx.pocoo.org/index.html
  534. .. Here below are coded the different aliases, reference, citation
  535. .. There do not appear like so in the text but can be use for references
  536. .. |logo| image:: _static/images/logo.png
  537. :width: 20pt
  538. :height: 20pt
  539. :align: middle
  540. .. |longtext| replace:: this is a longish text to include within a table and which is longer than the width of the column.
  541. Useful extensions
  542. #########################
  543. In the special file called **conf.py**, there is a variable called **extensions**. You can add extension in this variable. For instance::
  544. extensions = [-
  545. 'easydev.copybutton',
  546. 'sphinx.ext.autodoc',
  547. 'sphinx.ext.autosummary',
  548. 'sphinx.ext.coverage',
  549. 'sphinx.ext.graphviz',
  550. 'sphinx.ext.doctest',
  551. 'sphinx.ext.intersphinx',
  552. 'sphinx.ext.todo',
  553. 'sphinx.ext.coverage',
  554. 'sphinx.ext.pngmath',
  555. 'sphinx.ext.ifconfig',
  556. 'matplotlib.sphinxext.only_directives',
  557. 'matplotlib.sphinxext.plot_directive',
  558. ]
  559. pngmath: Maths and Equations with LaTeX
  560. ============================================
  561. The extension to be added is the pngmath from sphinx::
  562. extensions.append('sphinx.ext.pngmath')
  563. In order to include equations or simple Latex code in the text (e.g., :math:`\alpha \leq \beta` ) use the following code::
  564. :math:`\alpha > \beta`
  565. .. warning::
  566. The *math* markup can be used within RST files (to be parsed by Sphinx) but within your python's docstring, the slashes need to be escaped ! ``:math:`\alpha``` should therefore be written ``:math:`\\alpha``` or put an "r" before the docstring
  567. Note also, that you can easily include more complex mathematical expressions using the math directive::
  568. .. math::
  569. n_{\mathrm{offset}} = \sum_{k=0}^{N-1} s_k n_k
  570. Here is another:
  571. .. math:: n_{\mathrm{offset}} = \sum_{k=0}^{N-1} s_k n_k
  572. It seems that there is no limitations to LaTeX usage:
  573. .. math::
  574. s_k^{\mathrm{column}} = \prod_{j=0}^{k-1} d_j , \quad s_k^{\mathrm{row}} = \prod_{j=k+1}^{N-1} d_j .
  575. TODO extension
  576. =================
  577. Similarly to the note directive, one can include todo boxes but it requires the `sphinx.ext.todo` extension to be added in the **conf.py** file by adding two lines of code::
  578. extensions.append('sphinx.ext.todo')
  579. todo_include_todos=True
  580. ::
  581. .. todo:: a todo box
  582. .. rubric:: Footnotes
  583. .. [#footnote1] this is a footnote aimed at illustrating the footnote capability.
  584. .. rubric:: Bibliography
  585. .. [CIT2002] A citation
  586. (as often used in journals).
  587. .. _Git Tutorial: https://try.github.io/levels/1/challenges/1
  588. .. _Git Install: http://git-scm.com/book/en/Getting-Started-Installing-Git
  589. .. _Atlassian Git site: https://www.atlassian.com/git/tutorials