|
| 1 | +.. _write: |
| 2 | + |
| 3 | +Write |
| 4 | +===== |
| 5 | + |
| 6 | +The ``write`` command is used to generate file formats such as reStructuredText from the markers extracted by the ``analyse`` command. |
| 7 | +This allows you to create documentation that includes links to source code based on the need ids specified in your code comments. |
| 8 | + |
| 9 | +Example usage |
| 10 | +------------- |
| 11 | + |
| 12 | +With the following extracted markers fron the ``analyse`` command, |
| 13 | + |
| 14 | +.. code-block:: json |
| 15 | +
|
| 16 | + { |
| 17 | + "my_project": [ |
| 18 | + { |
| 19 | + "filepath": "/home/demo/git_repo/ub/sphinx-codelinks/tests/data/need_id_refs/dummy_1.cpp", |
| 20 | + "remote_url": "https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3", |
| 21 | + "source_map": { |
| 22 | + "start": {"row": 2, "column": 13}, |
| 23 | + "end": {"row": 2, "column": 51} |
| 24 | + }, |
| 25 | + "tagged_scope": "void dummy_func1(){\n //...\n }", |
| 26 | + "need_ids": ["NEED_001", "NEED_002", "NEED_003", "NEED_004"], |
| 27 | + "marker": "@need-ids:", |
| 28 | + "type": "need-id-refs" |
| 29 | + }, |
| 30 | + ], |
| 31 | + } |
| 32 | +
|
| 33 | +The following RST file with :external+needs:ref:`needextend <needextend>` directive can be generated by the ``write rst`` command: |
| 34 | + |
| 35 | +.. code-block:: rst |
| 36 | +
|
| 37 | + .. needextend:: NEED_001 |
| 38 | + :remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3 |
| 39 | +
|
| 40 | + .. needextend:: NEED_002 |
| 41 | + :remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3 |
| 42 | +
|
| 43 | + .. needextend:: NEED_003 |
| 44 | + :remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3 |
| 45 | +
|
| 46 | + .. needextend:: NEED_004 |
| 47 | + :remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3 |
| 48 | +
|
| 49 | +More examples can be found in `test cases <https://github.com/useblocks/sphinx-codelinks/blob/main/tests/test_needextend_write.py>`__ |
0 commit comments