Skip to content

Commit

Permalink
add trike-function etc aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
bkietz committed Nov 8, 2024
1 parent eacdd93 commit 4332054
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
31 changes: 27 additions & 4 deletions cmake_modules/trike/trike/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,18 @@ def cpp(self):
else:
self.env.temp_data[key] = value

def get_directive(self) -> tuple[str, str]:
arguments = list(self.arguments)
if self.name == "trike-put":
directive = arguments.pop(0)
elif self.name == "trike-macro":
directive = "c:macro"
else:
directive = "cpp:" + self.name.removeprefix("trike-")
return directive, " ".join(filter(lambda arg: arg != "\\", arguments))

def run(self) -> list[Node]:
directive = self.arguments[0]
argument = " ".join(filter(lambda arg: arg != "\\", self.arguments[1:]))
directive, argument = self.get_directive()
namespace = self.env.temp_data.get("cpp:namespace_stack", [""])[-1]
module = self.env.temp_data.get("cpp:module", "")
with_members = "members" in self.options
Expand Down Expand Up @@ -581,8 +590,22 @@ def setup(app: Sphinx) -> ExtensionMetadata:
)

app.connect("builder-inited", _builder_inited)
app.add_directive("trike-put", PutDirective)
# TODO trike-function etc as a shortcut for trike-put:: cpp:function
for name in [
"put",
"class",
"struct",
"function",
"member",
"var",
"type",
"enum",
"enum-struct",
"enum-class",
"enumerator",
"union",
"concept",
]:
app.add_directive(f"trike-{name}", PutDirective)

app.add_directive_to_domain("cpp", "module", CppModuleDirective)

Expand Down
14 changes: 7 additions & 7 deletions testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ specify resources which should be shared across the suite.
Unit test API
~~~~~~~~~~~~~

.. trike-put:: c:macro TEST_(case_name, parameters...)
.. trike-macro:: TEST_(case_name, parameters...)

.. trike-put:: c:macro EXPECT_(condition...)
.. trike-macro:: EXPECT_(condition...)

.. trike-put:: c:macro SUITE_
.. trike-macro:: SUITE_

.. cpp:module:: test_

.. trike-put:: cpp:class template <typename Match, \
typename Describe, \
typename DescribeNegation> \
Matcher
.. trike-class:: template <typename Match, \
typename Describe, \
typename DescribeNegation> \
Matcher

.. FIXME GTest is not easily includable yet
Expand Down
2 changes: 1 addition & 1 deletion zen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Zen
.. cpp:module:: maud_

.. trike-put:: cpp:struct Parameter : c4::yml::ConstNodeRef
.. trike-struct:: Parameter : c4::yml::ConstNodeRef
:members:

.. FIXME remove this when I figure out how to test sphinx better

0 comments on commit 4332054

Please sign in to comment.