|
1 | | -============= |
2 | | -API Reference |
3 | | -============= |
| 1 | +============== |
| 2 | +API References |
| 3 | +============== |
4 | 4 |
|
5 | | -Data Types |
6 | | -========== |
| 5 | +The Render Pipeline |
| 6 | +=================== |
7 | 7 |
|
8 | | -.. autotype:: sphinxnotes.render.PlainValue |
9 | | -.. autotype:: sphinxnotes.render.Value |
| 8 | +The pipeline defines how nodes carrying data are generated and when they are |
| 9 | +rendered as part of the document. |
10 | 10 |
|
11 | | -.. autoclass:: sphinxnotes.render.RawData |
12 | | -.. autoclass:: sphinxnotes.render.ParsedData |
| 11 | +1. Generation: :py:class:`~sphinxnotes.render.BaseContextRole`, |
| 12 | + :py:class:`~sphinxnotes.render.BaseContextDirective` and their subclasses |
| 13 | + create :py:class:`~sphinxnotes.render.pending_node` on document parsing, |
| 14 | + and the node will be inserted to the document tree. The node contains: |
13 | 15 |
|
14 | | -.. autoclass:: sphinxnotes.render.Field |
15 | | -.. autoclass:: sphinxnotes.render.Schema |
| 16 | + - :ref:`context`, the dynamic content of a Jinja template |
16 | 17 |
|
17 | | -.. autoclass:: sphinxnotes.render.data.Registry |
| 18 | + - :py:class:`~sphinxnotes.render.Template`, |
| 19 | + the Jinja template for rendering context to markup text |
| 20 | + (reStructuredText or Markdown) |
18 | 21 |
|
19 | | - .. automethod:: add_type |
20 | | - .. automethod:: add_form |
21 | | - .. automethod:: add_flag |
22 | | - .. automethod:: add_by_option |
| 22 | +2. Render: the ``pending_node`` node will be rendered at the appropriate |
| 23 | + :py:class:`~sphinxnotes.render.Phase`, depending on |
| 24 | + :py:attr:`~sphinxnotes.render.pending_node.template.phase`. |
23 | 25 |
|
24 | | - .. autotype:: sphinxnotes.render.data.ByOptionStore |
| 26 | +Node |
| 27 | +----- |
25 | 28 |
|
26 | | -The Render Pipeline |
27 | | -=================== |
| 29 | +.. autoclass:: sphinxnotes.render.pending_node |
| 30 | + |
| 31 | +.. _context: |
28 | 32 |
|
29 | 33 | Context |
30 | 34 | ------- |
31 | 35 |
|
32 | | -.. autoclass:: sphinxnotes.render.PendingContext |
| 36 | +Context refers to the dynamic content of a Jinja template. It can be: |
| 37 | + |
| 38 | +:py:class:`~sphinxnotes.render.ResolvedContext`: |
| 39 | + Our dedicated data type (:py:class:`sphinxnotes.render.ParsedData`), or any |
| 40 | + Python ``dict``. |
| 41 | + |
| 42 | +:py:class:`~sphinxnotes.render.PendingContext`: |
| 43 | + Context that is not yet available. For example, it may contain |
| 44 | + :py:class:`unparsed data <sphinxnotes.render.RawData>`, |
| 45 | + remote data, and more. |
| 46 | + |
| 47 | + :py:class:`PendingContext` can be resolved to |
| 48 | + :py:class:`~sphinxnotes.render.ResolvedContext` by calling |
| 49 | + :py:meth:`~sphinxnotes.render.PendingContext.resolve`. |
| 50 | + |
33 | 51 | .. autotype:: sphinxnotes.render.ResolvedContext |
34 | | -.. autoclass:: sphinxnotes.render.UnparsedData |
35 | 52 |
|
36 | | -.. autoclass:: sphinxnotes.render.pending_node |
| 53 | +.. autoclass:: sphinxnotes.render.PendingContext |
| 54 | + :members: resolve |
37 | 55 |
|
38 | | -Extra Context |
39 | | -------------- |
| 56 | +``PendingContext`` Implementations |
| 57 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
40 | 58 |
|
41 | | -.. autoclass:: sphinxnotes.render.ExtraContextGenerator |
42 | | -.. autoclass:: sphinxnotes.render.ExtraContextRegistry |
| 59 | +.. autoclass:: sphinxnotes.render.UnparsedData |
| 60 | + :show-inheritance: |
| 61 | + |
| 62 | +.. _extractx: |
43 | 63 |
|
44 | 64 | Template |
45 | 65 | -------- |
46 | 66 |
|
47 | 67 | .. autoclass:: sphinxnotes.render.Template |
| 68 | + :members: |
| 69 | + |
48 | 70 | .. autoclass:: sphinxnotes.render.Phase |
| 71 | + :members: |
49 | 72 |
|
50 | | -Pipeline |
51 | | --------- |
| 73 | +Extra Context |
| 74 | +------------- |
| 75 | + |
| 76 | +.. autoclass:: sphinxnotes.render.GlobalExtraContxt |
| 77 | + |
| 78 | +.. autoclass:: sphinxnotes.render.ParsePhaseExtraContext |
| 79 | + |
| 80 | +.. autoclass:: sphinxnotes.render.ResolvePhaseExtraContext |
| 81 | + |
| 82 | +.. autoclass:: sphinxnotes.render.ExtraContextRegistry |
| 83 | + :members: |
| 84 | + |
| 85 | + |
| 86 | +Base Roles and Directives |
| 87 | +------------------------- |
| 88 | + |
| 89 | +Base Role Classes |
| 90 | +~~~~~~~~~~~~~~~~~ |
52 | 91 |
|
53 | 92 | .. autoclass:: sphinxnotes.render.BaseContextRole |
54 | | -.. autoclass:: sphinxnotes.render.BaseContextDirective |
| 93 | + :show-inheritance: |
| 94 | + :members: process_pending_node, queue_pending_node, queue_context, current_context, current_template |
| 95 | + |
55 | 96 | .. autoclass:: sphinxnotes.render.BaseDataDefineRole |
| 97 | + :show-inheritance: |
| 98 | + :members: process_pending_node, queue_pending_node, queue_context, current_schema, current_template |
| 99 | + |
| 100 | +Base Directive Classes |
| 101 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 102 | + |
| 103 | +.. autoclass:: sphinxnotes.render.BaseContextDirective |
| 104 | + :show-inheritance: |
| 105 | + :members: process_pending_node, queue_pending_node, queue_context, current_context, current_template |
| 106 | + |
56 | 107 | .. autoclass:: sphinxnotes.render.BaseDataDefineDirective |
| 108 | + :show-inheritance: |
| 109 | + :members: process_pending_node, queue_pending_node, queue_context, current_schema, current_template |
| 110 | + |
57 | 111 | .. autoclass:: sphinxnotes.render.StrictDataDefineDirective |
| 112 | + :show-inheritance: |
| 113 | + :members: derive |
| 114 | + |
| 115 | +Data, Field and Schema |
| 116 | +====================== |
| 117 | + |
| 118 | +.. autotype:: sphinxnotes.render.PlainValue |
| 119 | + |
| 120 | +.. autotype:: sphinxnotes.render.Value |
| 121 | + |
| 122 | +.. autoclass:: sphinxnotes.render.RawData |
| 123 | + :members: name, attrs, content |
| 124 | + :undoc-members: |
| 125 | + |
| 126 | +.. autoclass:: sphinxnotes.render.ParsedData |
| 127 | + :members: name, attrs, content |
| 128 | + :undoc-members: |
| 129 | + |
| 130 | +.. autoclass:: sphinxnotes.render.Field |
| 131 | + :members: parse |
| 132 | + |
| 133 | +.. autoclass:: sphinxnotes.render.Schema |
| 134 | + :members: name, attrs, content |
| 135 | + :undoc-members: |
| 136 | + |
| 137 | +.. autoclass:: sphinxnotes.render.data.Registry |
| 138 | + :members: |
| 139 | + |
| 140 | + .. autotype:: sphinxnotes.render.data.ByOptionStore |
58 | 141 |
|
59 | 142 | Registry |
60 | 143 | ======== |
61 | 144 |
|
| 145 | +Developers can extend this extension (for example, to support more data types |
| 146 | +or add new extra context) by adding new items to |
| 147 | +:py:class:`sphinxnotes.render.REGISTRY`. |
| 148 | + |
62 | 149 | .. autodata:: sphinxnotes.render.REGISTRY |
63 | 150 |
|
64 | 151 | .. autoclass:: sphinxnotes.render.Registry |
|
0 commit comments