| 1 |
========== |
| 2 |
Examples |
| 3 |
========== |
| 4 |
|
| 5 |
Various examples of Bootstrap styling applied to Sphinx constructs. You can |
| 6 |
view the `source <./_sources/examples.txt>`_ of this page to see the specific |
| 7 |
reStructuredText used to create these examples. |
| 8 |
|
| 9 |
Headings |
| 10 |
======== |
| 11 |
This is a first level heading (``h1``). |
| 12 |
|
| 13 |
Sub-Heading |
| 14 |
----------- |
| 15 |
This is a second level heading (``h2``). |
| 16 |
|
| 17 |
Sub-Sub-Heading |
| 18 |
~~~~~~~~~~~~~~~ |
| 19 |
This is a third level heading (``h3``). |
| 20 |
|
| 21 |
|
| 22 |
Code |
| 23 |
==== |
| 24 |
The Sphinx Bootstrap Theme uses Bootstrap styling for ``inline code text`` and |
| 25 |
:: |
| 26 |
|
| 27 |
multiline |
| 28 |
code text |
| 29 |
|
| 30 |
Here's an included example with line numbers. |
| 31 |
|
| 32 |
.. literalinclude:: ../../samples/helloworld.py |
| 33 |
:linenos: |
| 34 |
|
| 35 |
It also works with existing Sphinx highlighting: |
| 36 |
|
| 37 |
.. code-block:: html |
| 38 |
|
| 39 |
<html> |
| 40 |
<body>Hello World</body> |
| 41 |
</html> |
| 42 |
|
| 43 |
.. code-block:: python |
| 44 |
|
| 45 |
def hello(): |
| 46 |
"""Greet.""" |
| 47 |
return "Hello World" |
| 48 |
|
| 49 |
.. code-block:: javascript |
| 50 |
|
| 51 |
/** |
| 52 |
* Greet. |
| 53 |
*/ |
| 54 |
function hello(): { |
| 55 |
return "Hello World"; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
Admonitions |
| 60 |
=========== |
| 61 |
The Sphinx Bootstrap Theme uses the Bootstrap ``alert`` classes for Sphinx |
| 62 |
admonitions. |
| 63 |
|
| 64 |
Note |
| 65 |
---- |
| 66 |
.. note:: This is a **note**. |
| 67 |
|
| 68 |
Todo |
| 69 |
---- |
| 70 |
.. todo:: This is a **todo**. |
| 71 |
|
| 72 |
Warning |
| 73 |
------- |
| 74 |
.. warning:: This is a **warning**. |
| 75 |
|
| 76 |
Danger |
| 77 |
------ |
| 78 |
.. danger:: This is **danger**-ous. |
| 79 |
|
| 80 |
Footnotes |
| 81 |
========= |
| 82 |
I have footnoted a first item [#f1]_ and second item [#f2]_. |
| 83 |
|
| 84 |
.. rubric:: Footnotes |
| 85 |
.. [#f1] My first footnote. |
| 86 |
.. [#f2] My second footnote. |
| 87 |
|
| 88 |
Icons |
| 89 |
===== |
| 90 |
Icons are different in Bootstrap 2 and 3, so you will only see an |
| 91 |
icon below for the version of Bootstrap that we used to build these docs. |
| 92 |
|
| 93 |
Bootstrap 2 |
| 94 |
----------- |
| 95 |
The following template HTML: |
| 96 |
|
| 97 |
.. code-block:: html |
| 98 |
|
| 99 |
<span class="icon-star-empty"></span> |
| 100 |
|
| 101 |
translates to a neat star: |
| 102 |
|
| 103 |
.. raw:: html |
| 104 |
|
| 105 |
<span class="icon-star-empty"></span> |
| 106 |
|
| 107 |
Bootstrap 3 |
| 108 |
----------- |
| 109 |
The following template HTML: |
| 110 |
|
| 111 |
.. code-block:: html |
| 112 |
|
| 113 |
<span class="glyphicon glyphicon-star-empty"></span> |
| 114 |
|
| 115 |
translates to a neat star: |
| 116 |
|
| 117 |
.. raw:: html |
| 118 |
|
| 119 |
<span class="glyphicon glyphicon-star-empty"></span> |
| 120 |
|
| 121 |
Tables |
| 122 |
====== |
| 123 |
Here are some examples of Sphinx |
| 124 |
`tables <http://sphinx-doc.org/rest.html#rst-tables>`_. The Sphinx Bootstrap |
| 125 |
Theme removes all Sphinx ``docutils`` classes and replaces them with the |
| 126 |
default Bootstrap ``table`` class. You can add additional table classes |
| 127 |
using the Sphinx ``cssclass::`` directive, as demonstrated in the following |
| 128 |
tables. |
| 129 |
|
| 130 |
Grid |
| 131 |
---- |
| 132 |
A "**bordered**" grid table: |
| 133 |
|
| 134 |
.. cssclass:: table-bordered |
| 135 |
|
| 136 |
+------------------------+------------+----------+----------+ |
| 137 |
| Header1 | Header2 | Header3 | Header4 | |
| 138 |
+========================+============+==========+==========+ |
| 139 |
| row1, cell1 | cell2 | cell3 | cell4 | |
| 140 |
+------------------------+------------+----------+----------+ |
| 141 |
| row2 ... | ... | ... | | |
| 142 |
+------------------------+------------+----------+----------+ |
| 143 |
| ... | ... | ... | | |
| 144 |
+------------------------+------------+----------+----------+ |
| 145 |
|
| 146 |
which uses the directive:: |
| 147 |
|
| 148 |
.. cssclass:: table-bordered |
| 149 |
|
| 150 |
Simple |
| 151 |
------ |
| 152 |
A simple "**striped**" table: |
| 153 |
|
| 154 |
.. cssclass:: table-striped |
| 155 |
|
| 156 |
===== ===== ======= |
| 157 |
H1 H2 H3 |
| 158 |
===== ===== ======= |
| 159 |
cell1 cell2 cell3 |
| 160 |
... ... ... |
| 161 |
... ... ... |
| 162 |
===== ===== ======= |
| 163 |
|
| 164 |
which uses the directive:: |
| 165 |
|
| 166 |
.. cssclass:: table-striped |
| 167 |
|
| 168 |
And a "**hoverable**" table: |
| 169 |
|
| 170 |
.. cssclass:: table-hover |
| 171 |
|
| 172 |
===== ===== ======= |
| 173 |
H1 H2 H3 |
| 174 |
===== ===== ======= |
| 175 |
cell1 cell2 cell3 |
| 176 |
... ... ... |
| 177 |
... ... ... |
| 178 |
===== ===== ======= |
| 179 |
|
| 180 |
which uses the directive:: |
| 181 |
|
| 182 |
.. cssclass:: table-hover |
| 183 |
|
| 184 |
Code Documentation |
| 185 |
================== |
| 186 |
|
| 187 |
An example Python function. |
| 188 |
|
| 189 |
.. py:function:: format_exception(etype, value, tb[, limit=None]) |
| 190 |
|
| 191 |
Format the exception with a traceback. |
| 192 |
|
| 193 |
:param etype: exception type |
| 194 |
:param value: exception value |
| 195 |
:param tb: traceback object |
| 196 |
:param limit: maximum number of stack frames to show |
| 197 |
:type limit: integer or None |
| 198 |
:rtype: list of strings |
| 199 |
|
| 200 |
An example JavaScript function. |
| 201 |
|
| 202 |
.. js:class:: MyAnimal(name[, age]) |
| 203 |
|
| 204 |
:param string name: The name of the animal |
| 205 |
:param number age: an optional age for the animal |