diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-11 08:48:25 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-19 11:29:34 +0200 |
commit | 1d3866a30eea88ff99d4aceda53c4871f61c11c0 (patch) | |
tree | 0828740a4ed4603817e9f43594e43e9465fbbb5e /rtemsspec/sphinxcontent.py | |
parent | spec: Fix item format (diff) | |
download | rtems-central-1d3866a30eea88ff99d4aceda53c4871f61c11c0.tar.bz2 |
content: Add to_camel_case()
Diffstat (limited to 'rtemsspec/sphinxcontent.py')
-rw-r--r-- | rtemsspec/sphinxcontent.py | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py index 85c7858c..914e2436 100644 --- a/rtemsspec/sphinxcontent.py +++ b/rtemsspec/sphinxcontent.py @@ -25,10 +25,9 @@ # POSSIBILITY OF SUCH DAMAGE. from contextlib import contextmanager -import re from typing import Any, Iterable, Iterator, List, Optional, Union -from rtemsspec.content import Content, make_lines +from rtemsspec.content import Content, make_lines, to_camel_case from rtemsspec.items import Item, ItemGetValueContext, ItemMapper GenericContent = Union[str, List[str], "Content"] @@ -38,12 +37,6 @@ GenericContentIterable = Union[Iterable[str], Iterable[List[str]], _HEADER_LEVELS = ["#", "*", "=", "-", "^", "\""] -def _to_camel_case(name: str) -> str: - return name[0].upper() + re.sub( - r"\s+(.)", lambda match: match.group(1).upper(), - re.sub(r"[^ \t\n\r\f\va-zA-Z0-9]", " ", name[1:].replace("+", "X"))) - - def get_reference(label: str, name: Optional[str] = None) -> str: """ Returns the reference to the specified label. """ if name: @@ -53,7 +46,7 @@ def get_reference(label: str, name: Optional[str] = None) -> str: def get_label(name: str) -> str: """ Returns the label for the specified name. """ - return _to_camel_case(name.strip()) + return to_camel_case(name.strip()) class SphinxContent(Content): |