-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support numeric cpp udls (swev-id: sphinx-doc__sphinx-7590) #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sphinx-doc__sphinx-7590
Are you sure you want to change the base?
Changes from all commits
e525009
efc87a8
cfce9e0
78455e2
4c18ac5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| exclude_patterns = ['_build'] | ||
| cpp_id_attributes = ['inline'] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| Invalid user-defined literal suffixes | ||
| ===================================== | ||
|
|
||
| .. cpp:var:: constexpr auto bad_mixed = 1.0f_qs | ||
|
|
||
| .. cpp:var:: constexpr auto bad_order = 1llu_qs | ||
|
|
||
| .. cpp:var:: constexpr auto bad_digit_suffix = 1e-34q1 | ||
|
|
||
| .. cpp:var:: constexpr auto bad_symbol = 8_invalid* | ||
|
|
||
| .. note:: | ||
|
|
||
| Literals with digit-prefixed suffixes such as ``1e-34_1q`` are valid and | ||
| covered by the positive tests; omitting the underscore as in ``1e-34q1`` is | ||
| invalid. | ||
|
|
||
| .. cpp:var:: constexpr auto bad_ws = 1 ud | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| Numeric user-defined literals | ||
| ============================== | ||
|
|
||
| .. cpp:var:: constexpr auto udl_decimal = 42_km | ||
|
|
||
| .. cpp:var:: constexpr auto udl_hex = 0x2A_km | ||
|
|
||
| .. cpp:var:: constexpr auto udl_binary = 0b1010_unit | ||
|
|
||
| .. cpp:var:: constexpr auto udl_float = 3.14_q_s | ||
|
|
||
| .. cpp:var:: constexpr auto hf1 = 0x1.0p+2ud | ||
|
|
||
| .. cpp:var:: constexpr auto hf2 = 0x1p2_ud | ||
|
|
||
| .. cpp:var:: constexpr auto iu1 = 42f_s | ||
|
|
||
| .. cpp:var:: constexpr auto iu2 = 10Funit | ||
|
|
||
| .. cpp:var:: constexpr auto udl_digit_float = 1e-34_1q | ||
|
|
||
| .. cpp:var:: constexpr auto udl_digit_int = 42_1q | ||
|
|
||
| .. cpp:namespace:: units::si | ||
|
|
||
| .. cpp:var:: inline constexpr auto planck_constant = 6.62607015e-34q_J * 1q_s | ||
|
|
||
|
|
||
| Builtin literal suffix regression | ||
| --------------------------------- | ||
|
|
||
| .. cpp:var:: constexpr auto builtin_u = 1u | ||
|
|
||
| .. cpp:var:: constexpr auto builtin_U = 1U | ||
|
|
||
| .. cpp:var:: constexpr auto builtin_l = 1l | ||
|
|
||
| .. cpp:var:: constexpr auto builtin_L = 1L | ||
|
|
||
| .. cpp:var:: constexpr auto builtin_f = 1.0f | ||
|
|
||
| .. cpp:var:: constexpr auto builtin_F = 1.0F | ||
|
|
||
| .. note:: | ||
|
|
||
| Digit separator examples such as ``1'000_km`` remain unsupported by the | ||
| test fixtures due to the base literal regular expressions. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -921,6 +921,20 @@ def test_build_domain_cpp_semicolon(app, status, warning): | |
| assert len(ws) == 0 | ||
|
|
||
|
|
||
| @pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True}, freshenv=True) | ||
| def test_build_domain_cpp_udl_numeric(app, status, warning): | ||
| app.builder.build_all() | ||
| ws = filter_warnings(warning, "udl-numeric") | ||
| assert len(ws) == 0 | ||
|
|
||
|
|
||
| @pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True}, freshenv=True) | ||
| def test_build_domain_cpp_udl_negative(app, status, warning): | ||
| app.builder.build_all() | ||
| ws = filter_warnings(warning, "udl-negative") | ||
| assert len(ws) == 4 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [major] Once |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [major] Once |
||
|
|
||
| @pytest.mark.sphinx(testroot='domain-cpp', | ||
| confoverrides={'nitpicky': True, 'strip_signature_backslash': True}) | ||
| def test_build_domain_cpp_backslash_ok(app, status, warning): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] This case should not be considered invalid.
_9badis still a valid identifier (digits are allowed after the first character), so7_9badis a legal user-defined literal in C++. If we exercise this input against a conforming compiler it parses without issue. Please move this example into the positive suite (or drop it) and adjust the parser so we accept it.