xoa.cfgm.cfg2rst

xoa.cfgm.cfg2rst(cfg, mode='basic', optrole='confopt', secrole='confsec', **kwargs)[source]

Convert a configuration to rst format

Configuration sections are declared by default with the rst confsec directive and options are declared with the rst confopt directive

For instance:

a=1 # desc a
[s1] # desc s1
    b=2  # desc b
    [[s2]] # desc s2
        c=$a-$b # desd c
        [sec1] # section 1

is converted to:

.. confopt:: a

    desc a

.. confsec:: [s1]

    desc s1

    .. confopt:: [s1] b

        desc b

    .. confsec:: [s1][s2]

        desc s2

        .. confopt:: [s1][s2] c

            desd c

Then one can reference an option with for example :confopt:`[s1][s2]c`.

Parameters:
  • cfg (configobj.ConfigObj, ConfigManager) – In the case of a ConfigManager, the get_defaults() are used.

  • mode ({"basic", "values", "specs"}) –

    "basic":

    Only display the config section and option names and description.

    "values":

    Also display the option values. A classic config.

    "specs":

    Also display the type and default value. Config specifications are expected for cfg.

Returns:

str