CadQuery / CadQuery/cadquery

Adding a cq_test directive

Open
#812 3 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

Say I write the following in the docs:
```rst
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
```python
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: https://github.com/CadQuery/cadquery/blob/3cb72378b895398b4b5f6129f46b8866c2618067/tests/test_examples.py#L39
by adding the line:
```python
directives.register_directive("cq_test", dummy_cq_directive)
```

and now my RST would be:
```rst
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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.