Skip to content

Commit

Permalink
Test for docstring with escape characters
Browse files Browse the repository at this point in the history
We test explicitly what happens with special characters which are
represented as literals in docstrings in the intermediate stage.

See [this StackOverflow question] for the background.

[this StackOverflow question]: https://stackoverflow.com/questions/57265111/escape-special-characters-in-restructuredtext-sphinx
  • Loading branch information
mristin committed Nov 7, 2023
1 parent f157c24 commit 15d084e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
SymbolTable(
our_types=[
ConstrainedPrimitive(
name='Non_empty_XML_serializable_string',
inheritances=[],
inheritance_id_set=...,
ancestors=[],
ancestor_id_set=...,
descendant_id_set=...,
constrainee='STR',
is_implementation_specific=False,
invariants=[],
invariant_id_set=...,
description=DescriptionOfOurType(
summary='<paragraph>Represent a string with at least one character.</paragraph>',
remarks=[
textwrap.dedent("""\
<paragraph>The string should also be serializable to XML, which is the background for
the following constraint.</paragraph>""")],
constraints_by_identifier=[
[
'AASd-130',
textwrap.dedent("""\
<field_body><paragraph>An attribute with data type "string" shall consist of these characters only:
<literal>^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\u00010000-\\u0010FFFF]*$</literal>.</paragraph></field_body>""")]],
parsed=...),
parsed=...)],
our_types_topologically_sorted=[
'Reference to our type Non_empty_XML_serializable_string'],
enumerations=[],
constrained_primitives=[
'Reference to our type Non_empty_XML_serializable_string'],
classes=[],
concrete_classes=[],
constants=[],
constants_by_name=...,
verification_functions=[],
verification_functions_by_name=...,
meta_model=MetaModel(
description=None,
version='dummy',
xml_namespace='https://dummy.com'))
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# We test for ``\x09`` and other special characters, and make sure they are represented
# adequately in the string dump of the symbol table.


class Non_empty_XML_serializable_string(str, DBC):
r"""
Represent a string with at least one character.
The string should also be serializable to XML, which is the background for
the following constraint.
:constraint AASd-130:
An attribute with data type "string" shall consist of these characters only:
``^[\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u00010000-\u0010FFFF]*$``.
"""


__version__ = "dummy"
__xml_namespace__ = "https://dummy.com"
Binary file not shown.

0 comments on commit 15d084e

Please sign in to comment.