File size: 2,658 Bytes
cb65407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Domain Tools
============

This `Sphinx extension`_ provides a tool for easy `sphinx domain`_ creation.

.. _Sphinx extension: http://sphinx-doc.org
.. _sphinx domain: http://sphinx-doc.org/domains.html


Installation
------------

::

    pip install sphinxcontrib-domaintools


Usage
-----

In this example there is created a simple domain for `GNU Make`_::

    from sphinxcontrib.domaintools import custom_domain

    def setup(app):
        app.add_domain(custom_domain('GnuMakeDomain',
            name  = 'make',
            label = "GNU Make", 

            elements = dict(
                target = dict(
                    objname      = "Make Target",
                    indextemplate = "pair: %s; Make Target",
                ),
                var   = dict(
                    objname = "Make Variable",
                    indextemplate = "pair: %s; Make Variable"
                ),
            )))

.. _GNU Make: http://www.gnu.org/software/make/

Complete example you find in `sphinxcontrib.makedomain`_ package.

A more complex example you can find in `sphinxcontrib-cmakedomain`_ package.

.. _sphinxcontrib-cmakedomain: http://bitbucket.org/klorenz/sphinxcontrib-cmakedomain
.. _sphinxcontrib-makedomain: http://bitbucket.org/klorenz/sphinxcontrib-makedomain


Reference
---------

.. py:function:: custom_domain(class_name, name='', label='', elements = {}):

    Create a custom domain.

    For each given element there are created a directive and a role
    for referencing and indexing.

    :param class_name: ClassName of your new domain (e.g. `GnuMakeDomain`)
    :param name      : short name of your domain (part of directives, e.g. `make`)
    :param label     : Long name of your domain (e.g. `GNU Make`)
    :param elements  :
        dictionary of your domain directives/roles

        An element value is a dictionary with following possible entries:

        - `objname` - Long name of the entry, defaults to entry's key

        - `role` - role name, defaults to entry's key

        - `indextemplate` - e.g. ``pair: %s; Make Target``, where %s will be 
          the matched part of your role.  You may leave this empty, defaults 
          to ``pair: %s; <objname>``

        - `parse_node` - a function with signature ``(env, sig, signode)``,
          defaults to `None`.

        - `fields` - A list of fields where parsed fields are mapped to. this
          is passed to Domain as `doc_field_types` parameter.

        - `ref_nodeclass` - class passed as XRefRole's innernodeclass,
          defaults to `None`.


License
-------

New BSD License.


Author
------

`Kay-Uwe (Kiwi) Lorenz <tabkiwi@gmail.com>`_