Skip to content

Adding a cq_test directive #812

@marcus7070

Description

@marcus7070

Say I write the following in the docs:

The ``tag`` method is unusual for a Workplane method in that it returns the same Workplane object, not a new one.

Immediately after that I would like to write a test like

a = cq.Workplane()
b = a.tag("_")
assert a == b

Now if that test ever fails, I can fix my statement in the docs that I have long since forgot because I have the attention span of a caffeinated chipmunk.

If we created a directive in docs/cq_directive called cq_test that instructed Sphinx to just do nothing with the content (ie. no output in docs), then we could collect them during testing like we currently do for the cadquery directive here:

directives.register_directive("cadquery", dummy_cq_directive)

by adding the line:

directives.register_directive("cq_test", dummy_cq_directive)

and now my RST would be:

The ``tag`` method is unusual for a Workplane method in that it returns the same Workplane object, not a new one.

.. cq_test::

    a = cq.Workplane()
    b = a.tag("_")
    assert a == b

and pytest would run that test.

Does all that sound good?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions