Skip to content

Commit

Permalink
Change Value Seperator to =, Add Space to Key Name
Browse files Browse the repository at this point in the history
Also fixed a few typos
  • Loading branch information
iguessthislldo committed Apr 1, 2024
1 parent 8fd9b85 commit fa0a9d8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
12 changes: 6 additions & 6 deletions docs/devguide/run_time_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3411,7 +3411,7 @@ The highest level logging is controlled by the general log levels listed in the

N/A

- :val:`DCPSLogLevel:none`
- :val:`DCPSLogLevel=none`

``log_level``: ``LogLevel::None``

Expand All @@ -3423,7 +3423,7 @@ The highest level logging is controlled by the general log levels listed in the

Error

- :val:`DCPSLogLevel:error`
- :val:`DCPSLogLevel=error`

``log_level``: ``LogLevel::Error``

Expand All @@ -3435,7 +3435,7 @@ The highest level logging is controlled by the general log levels listed in the

Warning

- :val:`DCPSLogLevel:warning`
- :val:`DCPSLogLevel=warning`

``log_level``: ``LogLevel::Warning``

Expand All @@ -3448,7 +3448,7 @@ The highest level logging is controlled by the general log levels listed in the

Notice

- :val:`DCPSLogLevel:notice`
- :val:`DCPSLogLevel=notice`

``log_level``: ``LogLevel::Notice``

Expand All @@ -3460,7 +3460,7 @@ The highest level logging is controlled by the general log levels listed in the

Info

- :val:`DCPSLogLevel:info`
- :val:`DCPSLogLevel=info`

``log_level``: ``LogLevel::Info``

Expand All @@ -3472,7 +3472,7 @@ The highest level logging is controlled by the general log levels listed in the

Debug

- :val:`DCPSLogLevel:debug`
- :val:`DCPSLogLevel=debug`

``log_level``: ``LogLevel::Debug``

Expand Down
24 changes: 12 additions & 12 deletions docs/internal/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ For :doc:`/devguide/run_time_configuration` there's a custom configuration Sphin
Use to document a configuration key that can contain :rst:dir:`cfg:val` and most other RST content.
Must be in a :rst:dir:`cfg:sec`.
``<values>`` describe what sort of text is accepted.
It is just for display and has no restrictions on the contents, but should follow the following syntax conventions to describe the accepted values:
It is just for display and has no restrictions on the contents, but should follow the following conventions to describe the accepted values:

- ``|`` indicates an OR
- ``[]`` indicates an optional part of the value
Expand All @@ -506,7 +506,7 @@ For :doc:`/devguide/run_time_configuration` there's a custom configuration Sphin
.. rst:directive:option:: default
The default value of the key if ommitted
The default value of the key if omitted
.. rst:role:: cfg:key
Expand Down Expand Up @@ -538,13 +538,13 @@ For :doc:`/devguide/run_time_configuration` there's a custom configuration Sphin

This must be inside a :rst:dir:`cfg:key`.

- ``<key_name>:<val_name>``
- ``<key_name>=<val_name>``

Inside of a :rst:dir:`cfg:sec`, it refers to a value of a key in that section.
Outside of a :rst:dir:`cfg:sec`, the key is assumed to be ``common``.

- ``[<sect_name>]<key_name>:<val_name>``
- ``[<sect_name>@<disc_name>]<key_name>:<val_name>``
- ``[<sect_name>]<key_name>=<val_name>``
- ``[<sect_name>@<disc_name>]<key_name>=<val_name>``

Example
^^^^^^^
Expand All @@ -562,13 +562,13 @@ This is a example made up for the following INI file:
.. code-block:: rst
Outside their sections, references to keys and values must be complete: :cfg:val:`[server]os:linux`, :cfg:key:`[server@linux]distro`
Outside their sections, references to keys and values must be complete: :cfg:val:`[server]os=linux`, :cfg:key:`[server@linux]distro`
Otherwise the ``common`` section will be assumed.
.. cfg:sec:: server/<name>
A key or value's section can be omitted from references within their sections: :cfg:key:`os`, :cfg:val:`os:windows`
A key or value's section can be omitted from references within their sections: :cfg:key:`os`, :cfg:val:`os=windows`
.. cfg:key:: os=windows|linux
:required:
Expand All @@ -577,11 +577,11 @@ This is a example made up for the following INI file:
.. cfg:val:: windows
Implied titles will be shortened within their scopes: :cfg:key:`[server]os`, :cfg:val:`[server]os:windows`
Implied titles will be shortened within their scopes: :cfg:key:`[server]os`, :cfg:val:`[server]os=windows`
.. cfg:val:: linux
Sections with discriminators require them in the reference targets: cfg:sec:`server@linux`, :cfg:key:`[server@linux]distro`
Sections with discriminators require them in the reference targets: :cfg:sec:`server@linux`, :cfg:key:`[server@linux]distro`
.. cfg:sec:: server@linux/<name>
Expand All @@ -590,15 +590,15 @@ This is a example made up for the following INI file:
Turns into:

Outside their sections, references to keys and values must be complete: :cfg:val:`[server]os:linux`, :cfg:key:`[server@linux]distro`
Outside their sections, references to keys and values must be complete: :cfg:val:`[server]os=linux`, :cfg:key:`[server@linux]distro`

Otherwise the ``common`` section will be assumed.

.. cfg:sec:: server/<name>
:no-contents-entry:
:no-index-entry:

A key or value's section can be omitted from references within their sections: :cfg:key:`os`, :cfg:val:`os:windows`
A key or value's section can be omitted from references within their sections: :cfg:key:`os`, :cfg:val:`os=windows`

.. cfg:key:: os=windows|linux
:required:
Expand All @@ -611,7 +611,7 @@ Turns into:
:no-contents-entry:
:no-index-entry:

Implied titles will be shortened within their scopes: :cfg:key:`[server]os`, :cfg:val:`[server]os:windows`
Implied titles will be shortened within their scopes: :cfg:key:`[server]os`, :cfg:val:`[server]os=windows`

.. cfg:val:: linux
:no-contents-entry:
Expand Down
34 changes: 17 additions & 17 deletions docs/sphinx_extensions/config_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def parse_key_name(full_name, node=None):
def key_text(sec_name, sec_disc, key_name, insert=''):
text = key_name + insert
if sec_name is not None:
text = section_text(sec_name, sec_disc, text)
text = section_text(sec_name, sec_disc, ' ' + text)
return text


Expand Down Expand Up @@ -244,7 +244,9 @@ def transform_content(self, contentnode: addnodes.desc_content) -> None:

# cfg:val =====================================================================

value_re = r'(?:(?P<key>' + key_re + r'):)?(?P<val_name>' + id_re + r')'
value_sep = '='
value_sep_re = re.escape(value_sep)
value_re = r'(?:(?P<key>' + key_re + r')' + value_sep_re + r')?(?P<val_name>' + id_re + r')'


def parse_value_name(full_name, node=None):
Expand All @@ -255,7 +257,7 @@ def parse_value_name(full_name, node=None):
def value_text(sec_name, sec_disc, key_name, val_name):
text = val_name
if key_name is not None:
text = key_text(sec_name, sec_disc, key_name, ':' + text)
text = key_text(sec_name, sec_disc, key_name, value_sep + text)
return text


Expand All @@ -272,16 +274,14 @@ def process_link(self, env: BuildEnvironment, refnode: Element,
# [sec]key=val anywhere
pass
elif scope_kind == 0 and sec is None:
# key:val outside section
# key=val outside section
target = f'[common]{target}'
elif scope_kind >= 1 and key is not None:
# key:val anywhere in a section
prefix = ctx.get_full_name(0)
target = f'{prefix}{target}'
# key=val anywhere in a section
target = ctx.get_full_name(0) + target
elif scope_kind >= 2 and key is None:
# val anywhere in a key
prefix = ctx.get_full_name(1)
target = f'{prefix}:{target}'
target = ctx.get_full_name(1) + value_sep + target
else:
ConfigDomain.logger.warning(f'{repr(target)} is an invalid target here',
location=self.get_location())
Expand Down Expand Up @@ -323,7 +323,7 @@ def parse_sig(self, ctx, sig):
r'(' + id_re + r')|<(' + id_re + r')>', sig, self)
brackets = bool(name_w_brackets)
name = name_w_brackets if brackets else name_wo_brackets
ctx.push(self, name, ctx.get_full_name() + f':{name}')
ctx.push(self, name, ctx.get_full_name() + value_sep + name)
return (brackets,)

def create_signode(self, ctx, name, signode, brackets):
Expand Down Expand Up @@ -371,16 +371,16 @@ def test_parse_key_name(self):
for ref, expected in cases.items():
self.assertEqual(parse_key_name(ref), expected, f'On key {repr(ref)}')

def test_parse_key_name(self):
def test_parse_value_name(self):
cases = {
# sec, sec_name, sec_disc, key, key_name, val_name
'vn': (None, None, None, None, None, 'vn'),
'kn:vn': (None, None, None, 'kn', 'kn', 'vn'),
'kn.a.b.c:vn': (None, None, None, 'kn.a.b.c', 'kn.a.b.c', 'vn'),
'[sn]kn:vn': ('sn', 'sn', None, '[sn]kn', 'kn', 'vn'),
'[sn]kn.a.b.c:vn': ('sn', 'sn', None, '[sn]kn.a.b.c', 'kn.a.b.c', 'vn'),
'[sn@sd]kn:vn': ('sn@sd', 'sn', 'sd', '[sn@sd]kn', 'kn', 'vn'),
'[sn@sd]kn.a.b.c:vn': ('sn@sd', 'sn', 'sd', '[sn@sd]kn.a.b.c', 'kn.a.b.c', 'vn'),
'kn=vn': (None, None, None, 'kn', 'kn', 'vn'),
'kn.a.b.c=vn': (None, None, None, 'kn.a.b.c', 'kn.a.b.c', 'vn'),
'[sn]kn=vn': ('sn', 'sn', None, '[sn]kn', 'kn', 'vn'),
'[sn]kn.a.b.c=vn': ('sn', 'sn', None, '[sn]kn.a.b.c', 'kn.a.b.c', 'vn'),
'[sn@sd]kn=vn': ('sn@sd', 'sn', 'sd', '[sn@sd]kn', 'kn', 'vn'),
'[sn@sd]kn.a.b.c=vn': ('sn@sd', 'sn', 'sd', '[sn@sd]kn.a.b.c', 'kn.a.b.c', 'vn'),
}

for ref, expected in cases.items():
Expand Down

0 comments on commit fa0a9d8

Please sign in to comment.