Skip to content

Commit 8676047

Browse files
committed
Update documentation
1 parent 5b7e71d commit 8676047

File tree

20 files changed

+333
-377
lines changed

20 files changed

+333
-377
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@ semiwrap
22
========
33

44
This is a build tool intended to be generally useful for any python project
5-
that has binary dependencies. It is especially designed to meet the needs
6-
of RobotPy's various wrapper libraries, chiefly around:
5+
that wants to use pybind11 to create a Python API around C/C++ binary dependencies.
6+
7+
8+
9+
This is primarily intended to be used with hatchling and meson to build
10+
11+
This tool parses C/C++ headers
12+
13+
14+
It is especially designed to meet the needs of RobotPy's various wrapper
15+
libraries, chiefly around:
716

817
* Managing upstream binary dependencies
918
* Autogenerating pybind11 wrappers around those dependencies

docs/autowrap.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Automated C++ header wrapping
55
=============================
66

7-
robotpy-build can be told to parse C/C++ headers and automatically generate
7+
semiwrap can be told to parse C/C++ headers and automatically generate
88
:std:doc:`pybind11 <pybind11:basics>` wrappers around the functions
99
and objects found in that header.
1010

@@ -15,9 +15,9 @@ and objects found in that header.
1515
C++ Features
1616
------------
1717

18-
robotpy-build uses a pure python C++ parser and macro processor to attempt to
18+
semiwrap uses a pure python C++ parser and macro processor to attempt to
1919
parse header files. As a result, a full AST of the header files is not created.
20-
This means particularly opaque code might confuse the parser, as robotpy-build
20+
This means particularly opaque code might confuse the parser, as semiwrap
2121
only receives the names, not the actual type information.
2222

2323
However, most basic features typically work without needing to coerce the
@@ -34,6 +34,7 @@ generator into working correctly, including:
3434
* final classes/methods - cannot be overridden from Python code
3535
* Enumerations
3636
* Global variables
37+
* Many many more weird edge cases too
3738

3839
Additionally, the following features are supported, but require some manual
3940
intervention:
@@ -46,22 +47,22 @@ to your package in ``pyproject.toml``:
4647

4748
.. code-block:: toml
4849
49-
[tool.robotpy-build.wrappers."MYPACKAGE".autogen_headers]
50+
[tool.semiwrap.extension_modules."PACKAGE.NAME".headers]
5051
demo = "demo.h"
5152
5253
That causes ``demo.h`` to be parsed and wrapped.
5354

5455
.. note:: If you're importing a large number of headers, the
55-
``robotpy-build scan-headers`` tool can generate this for you
56+
``semiwrap scan-headers`` tool can generate this list for you
5657
automatically.
5758

5859
Documentation
5960
-------------
6061

61-
robotpy-build will find doxygen documentation comments on many types of elements
62-
and use sphinxify to translate them into python docstrings. All elements that
63-
support documentation strings can have their docstrings set explicitly using
64-
a ``doc`` value in the YAML file.
62+
semiwrap will find doxygen documentation comments on many types of elements
63+
and use sphinxify to translate them into python docstrings. If this is not
64+
sufficient, all elements that support documentation strings can have their
65+
docstrings set explicitly using a ``doc`` value in the YAML file.
6566

6667
.. code-block:: yaml
6768

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@
7272
# relative to this directory. They are copied after the builtin static files,
7373
# so a file named "default.css" will overwrite the builtin "default.css".
7474
html_static_path = []
75+

docs/config/autowrap.rst

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,68 @@
44
Generator Customization
55
=======================
66

7-
Because robotpy-build's code generation is intended to be a semi-automated
7+
Because semiwrap's code generation is intended to be a semi-automated
88
process (except for simple C++ code), a rich set of per-{class/function/parameter}
99
configuration options can be specified in per-file YAML configurations.
1010

1111
Additionally, some headers are too complex for the autogenerator to
1212
completely process, so when this occurs you must manually specify required
1313
information in the YAML file.
1414

15-
Most files generated by robotpy-build are customizable.
15+
Most files generated by semiwrap are customizable.
1616

17-
.. note:: robotpy-build is designed for the RobotPy project and may contain
17+
.. note:: semiwrap is designed for the RobotPy project and may contain
1818
defaults that aren't appropriate for all projects. If you find that
1919
you need more customization, file an issue on github and let's talk
2020
about it!
2121

2222
Location of customization file
2323
------------------------------
2424

25-
In your ``pyproject.toml``, you can specify either a single YAML file with
26-
customizations, or you can specify a directory that robotpy-build will search
27-
for YAML files.
28-
29-
Single file:
30-
31-
.. code-block:: toml
32-
33-
[tool.robotpy-build.wrappers."PACKAGENAME"]
34-
generation_data = "gen/data.yml"
35-
36-
Multiple files:
25+
By default customization files are located in the ``wrapcfg`` directory. The name
26+
of the YAML file is the ``key`` in the extension module headers table:
3727

3828
.. code-block:: toml
3929
40-
[tool.robotpy-build.wrappers."PACKAGENAME"]
41-
generation_data = "gen"
42-
43-
When a directory is specified, pybind11 will search for YAML files in the
44-
directory based on the header filename. In the above example, customization
45-
data for ``header.h`` could be specified in ``gen/header.yml``.
30+
[tool.semiwrap.extension_modules."PACKAGE.NAME".headers]
31+
# yaml file is `wrapcfg/demo.yml`
32+
demo = "include/demo.h"
4633
4734
4835
Autogeneration
4936
--------------
5037

51-
The default values for these YAML files can be generated via the robotpy-build
52-
command line tool:
38+
The default values for these YAML files should be generated via the semiwrap command
39+
line tool:
5340

5441
.. code-block:: sh
5542
56-
robotpy-build create-gen --write
43+
semiwrap create-gen --write
5744
5845
This can be a good way to get the boilerplate out of the way when you need to
5946
provide customizations.
6047

48+
Manual pybind11 APIs
49+
--------------------
50+
51+
You can write your own custom .cpp files and add them to the python extensions
52+
generated by semiwrap. In your ``meson.build`` after you include the generated
53+
``wrapcfg`` subdir, add files to ``NAME_sources``.
54+
55+
.. code-block:: meson
56+
57+
subdir('wrapcfg')
58+
59+
my_module_sources += files(
60+
'src/my_module/main.cpp',
61+
)
62+
63+
6164
Reference
6265
---------
6366

6467
The following strctures describe the dictionaries that are read from the YAML
65-
file. The toplevel structure is :class:`.AutowrapConfigYaml`.
68+
files. The toplevel structure is :class:`.AutowrapConfigYaml`.
6669

67-
.. automodule:: robotpy_build.config.autowrap_yml
70+
.. automodule:: semiwrap.config.autowrap_yml
6871
:members:
69-
:undoc-members:

docs/config/pyproject.rst

Lines changed: 9 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11

22
.. _pyproject:
33

4-
setup.py and pyproject.toml
5-
===========================
6-
7-
setup.py
8-
--------
9-
10-
Projects that use robotpy-build must use the setup function provided by
11-
robotpy-build. Your project's setup.py should look like this:
12-
13-
.. code-block:: py
4+
pyproject.toml
5+
==============
146

15-
#!/usr/bin/env python3
16-
from robotpy_build.setup import setup
17-
setup()
7+
semiwrap is
188

199
pyproject.toml
2010
--------------
2111

22-
Projects that use robotpy-build must add a ``pyproject.toml`` to the root of
12+
Projects that use semiwrap must add a ``pyproject.toml`` to the root of
2313
their project as specified in `PEP 518 <https://www.python.org/dev/peps/pep-0518>`_.
2414

2515
It is recommended that projects include the standard ``build-system`` section to
26-
tell pip to install robotpy-build (and any other dependencies) before starting
16+
tell pip to install semiwrap (and any other dependencies) before starting
2717
a build.
2818

2919
.. code-block:: toml
3020
3121
[build-system]
3222
requires = ["robotpy-build>=2020.1.0,<2021.0.0"]
3323
34-
Projects must include robotpy-build specific sections in their pyproject.toml.
35-
robotpy-build takes ``pyproject.toml`` and converts it to a python dictionary
24+
Projects must include semiwrap specific sections in their pyproject.toml.
25+
semiwrap takes ``pyproject.toml`` and converts it to a python dictionary
3626
using ``toml.load``. The resulting dictionary is given to pydantic, which
3727
validates the structure of the dictionary against the objects described below.
3828

@@ -49,73 +39,12 @@ Optional sections:
4939
* :class:`.PatchInfo` - patch downloaded sources
5040

5141

52-
.. note:: For a complete example pyproject.toml file, see ``tests/cpp/pyproject.toml.tmpl``
53-
54-
.. _pyproject_overrides:
55-
56-
Overrides
57-
---------
58-
59-
You can define 'override' sections that will be grafted onto the configuration
60-
if they match a particular platform. For example, to change the dependencies
61-
for a wrapper section on Windows:
62-
63-
.. code-block:: toml
64-
65-
[tool.robotpy-build.wrappers."PACKAGENAME".override.os_windows]
66-
depends = ["windows-thing"]
67-
68-
Any element in the robotpy-build section of pyproject.toml can be overridden
69-
by specifying the identical section as '.override.KEYNAME'. If the key matches
70-
the current configuration, the override will be written to the original section.
71-
The matched keys are generated at runtime. Current supported platform override
72-
keys are:
73-
74-
* ``arch_{platform_arch}``
75-
* ``os_{platform_os}``
76-
* ``platform_{platform_os}_{platform_arch}``
77-
78-
To get information about the current platform, you can run:
79-
80-
.. code-block:: sh
81-
82-
robotpy-build platform-info
83-
84-
To show the available platforms:
85-
86-
.. code-block:: sh
87-
88-
robotpy-build platform-info --list
89-
90-
To process a pyproject.toml and see the result of applying various overrides,
91-
you can use this tool to process for the current platform:
92-
93-
.. code-block:: sh
94-
95-
robotpy-build show-override
96-
97-
To show what would be processed for a different platform:
98-
99-
.. code-block:: sh
100-
101-
robotpy-build show-override -p linux-athena
102-
103-
.. _platforms:
104-
105-
Current supported platform/os/arch combinations are:
106-
107-
* OS: windows/osx/linux
108-
* Arch: x86/x86-64/armv7l/aarch64
109-
110-
For ARM linux distributions we support:
42+
.. note:: For a complete example pyproject.toml file, see ``tests/cpp/*/pyproject.toml``
11143

112-
* armv7l + nilrt (RoboRIO)
113-
* armv7l + raspbian (Raspbian 10)
114-
* aarch64 + bionic (Ubuntu 18.04)
11544

11645
Reference
11746
---------
11847

119-
.. automodule:: robotpy_build.config.pyproject_toml
48+
.. automodule:: semiwrap.config.pyproject_toml
12049
:members:
12150
:exclude-members: __init__, Config

0 commit comments

Comments
 (0)