|
1 | 1 | <img src="./logo.png" width="125" height="125" align="right" />
|
2 | 2 |
|
3 |
| -# rustpython-doc |
| 3 | +# `__doc__` for [RustPython](https://rustpython.github.io/) |
4 | 4 |
|
5 |
| -This `rustpython-doc` package contains all `__doc__` database in forms of `docs.inc.rs`. |
| 5 | +This is the `__doc__` attributes generator for objects written in RustPython. |
6 | 6 |
|
7 |
| -## How to update `__doc__` in RustPython |
| 7 | +It's composed of two parts of: |
8 | 8 |
|
9 |
| -Adding a remake in front of `[pyclass]` of `[pyfunction]` will simply make the documentation to themselves, however, we do not manually add docs anymore. |
| 9 | +- the `generate_docs.py` script that extracts the `__doc__` attributes from CPython to `docs.inc.rs` |
| 10 | +- the `rustpython-doc` rust crate that uses the `docs.inc.rs` file to create a documentation Database. |
10 | 11 |
|
11 |
| -> But we don't manually add docs anymore. We have an auto-generated document db. |
12 |
| -> |
13 |
| -> The db is generated by scripts/generate_docs.py and applied to each object and functions by rustpython-doc::Database (search for crate::doc::Database::shared() in source code) |
14 |
| -> |
15 |
| -> *- Originally posted by @youknowone in [RustPython#4205 (comment)](https://github.com/RustPython/RustPython/pull/4205)* |
| 12 | +This documentation database is then used by macros `pymodule` and `pyclass` macros of the rustpython-derive crate to automatically add the `__doc__` attribute. |
16 | 13 |
|
17 |
| -Therefore you must update `docs.in.rs`, if it is unnecessary to different from cpython's `__doc__` |
| 14 | +The `docs.inc.rs` database file can be generated with |
18 | 15 |
|
19 |
| -## How to update `docs.in.rs` |
| 16 | + $ python -m venv gendocs |
| 17 | + $ source gendocs/bin/activate |
| 18 | + $ python -I generate_docs.py <path_to_RustPython> docs.inc.rs |
| 19 | + $ deactivate |
20 | 20 |
|
21 |
| -To update `__doc__` for newer python version: |
| 21 | +or using docker |
22 | 22 |
|
23 |
| -``` |
24 |
| -$ python generate_docs.py {RustPython PATH} ./docs.inc.rs |
25 |
| -``` |
26 |
| -This will iterate all stdlib modules to inspect their `__doc__`, updating your local `docs.in.rs` file. Since RustPython is only able to access the database in this online package, the changes must be merged into this branch. |
| 23 | + $ docker pull python:slim |
| 24 | + $ docker run python:slim python --version |
| 25 | + Python 3.10.8 |
| 26 | + $ ls |
| 27 | + __doc__ RustPython |
| 28 | + $ docker run -v $(pwd):/RustPython -w /RustPython/__doc__ python:slim python generate_docs.py ../RustPython docs.inc.rs |
27 | 29 |
|
28 |
| -After that, update cargo: |
| 30 | + |
| 31 | +and do not forget to update cargo before the test |
29 | 32 | ```
|
30 | 33 | $ cargo update
|
31 | 34 | ```
|
32 | 35 | ## Why the `__doc__` is not changed?
|
33 | 36 |
|
34 |
| -### Check if it is related to the unclosed issue |
35 |
| -There is still some issue with `generate_docs.py` |
36 |
| -- https://github.com/RustPython/RustPython/issues/3973 |
| 37 | +### Check the old documentation implemented with remarks are still exist |
| 38 | +RustPython prioritizes the user define documentation. Check if the old remarks are remaining in the source code. If it is, simply removing them could solve the issue. |
| 39 | + |
| 40 | +## Contributing |
37 | 41 |
|
| 42 | +Contributions are more than welcome, and in many cases we are happy to guide |
| 43 | +contributors through PRs or on gitter. Please refer to the |
| 44 | +[development guide](https://github.com/RustPython/RustPython/DEVELOPMENT.md) as well for tips on developments. |
38 | 45 |
|
| 46 | +## License |
39 | 47 |
|
40 |
| -### Check if the old remark documentation are not removed yet |
| 48 | +This project is licensed under the MIT license. Please see the |
| 49 | +[LICENSE](https://github.com/RustPython/RustPython/LICENSE) file for more details. |
41 | 50 |
|
42 |
| -RustPython prioritizes the user define documentation first. Check if old remarks remaining in the source code, and remove them. |
| 51 | +The [project logo](https://github.com/RustPython/RustPython/logo.png) is licensed under the CC-BY-4.0 |
| 52 | +license. Please see the [LICENSE-logo](https://github.com/RustPython/RustPython/LICENSE-logo) file |
| 53 | +for more details. |
0 commit comments