|
1 | 1 | Quick Start
|
2 | 2 | ===========
|
3 | 3 |
|
4 |
| -``CodeLinks`` provides ``src-trace`` directive and it can be used in the following ways: |
| 4 | +.. image:: local_link.gif |
5 | 5 |
|
6 |
| -.. code-block:: rst |
| 6 | +Three steps to quickly run ``CodeLinks`` to achieve **the above**: |
7 | 7 |
|
8 |
| - .. src-trace:: example_with_file |
9 |
| - :project: project_config |
10 |
| - :file: example.cpp |
| 8 | +- Configure Sphinx |
| 9 | +- Apply One-line comment for a ``Sphinx-Needs`` need item |
| 10 | +- Use ``src-trace`` directive |
11 | 11 |
|
12 |
| -or |
13 |
| - |
14 |
| -.. code-block:: rst |
15 |
| -
|
16 |
| - .. src-trace:: example_with_directory |
17 |
| - :project: project_config |
18 |
| - :directory: ./example |
19 |
| -
|
20 |
| -``src-trace`` directive has the following options: |
21 |
| - |
22 |
| -* **project**: the project config specified in ``conf.py`` or ``toml`` file to be used for source tracing. |
23 |
| -* **file**: the source file to be traced. |
24 |
| -* **directory**: the source files in the directory to be traced recursively. |
25 |
| - |
26 |
| -Regarding the **file** and **directory** options: |
27 |
| - |
28 |
| -- they are optional and mutually exclusive. |
29 |
| -- the given paths are relative to ``src_dir`` defined in the source tracing configuration |
30 |
| -- if not given, the whole project will be examined. |
31 |
| - |
32 |
| -Example |
33 |
| -------- |
34 |
| - |
35 |
| -With the following configuration for a demo source code project `dcdc <https://github.com/useblocks/sphinx-codelinks/tree/main/tests/data/dcdc>`_, |
| 12 | +Sphinx Config |
| 13 | +------------- |
36 | 14 |
|
37 | 15 | .. code-block:: python
|
38 | 16 | :caption: conf.py
|
39 | 17 |
|
| 18 | + extensions = [ |
| 19 | + 'sphinx_needs', |
| 20 | + 'sphinx_codelinks' |
| 21 | + ] |
40 | 22 | src_trace_config_from_toml = "src_trace.toml"
|
41 | 23 |
|
42 | 24 | .. literalinclude:: ./../../src_trace.toml
|
43 | 25 | :caption: src_trace.toml
|
44 | 26 | :language: toml
|
| 27 | + :lines: 27-29 |
45 | 28 |
|
46 |
| -``src-trace`` directive can be used with **file** option: |
| 29 | +One-line comment |
| 30 | +---------------- |
47 | 31 |
|
48 |
| -.. code-block:: rst |
| 32 | +.. literalinclude:: ./../../../tests/doc_test/minimum_config/dummy_src.cpp |
| 33 | + :caption: dummy_src.cpp |
| 34 | + :language: cpp |
49 | 35 |
|
50 |
| - .. src-trace:: dcdc demo_1 |
51 |
| - :project: dcdc |
52 |
| - :file: ./charge/demo_1.cpp |
53 | 36 |
|
54 |
| -The needs defined in source code are extracted and rendered to: |
| 37 | +Directive |
| 38 | +--------- |
55 | 39 |
|
56 |
| -.. src-trace:: dcdc demo_1 |
57 |
| - :project: dcdc |
58 |
| - :file: ./charge/demo_1.cpp |
| 40 | +.. literalinclude:: ./../../../tests/doc_test/minimum_config/index.rst |
| 41 | + :caption: index.rst |
| 42 | + :language: rst |
59 | 43 |
|
60 |
| -``src-trace`` directive can be used with **directory** option: |
61 | 44 |
|
62 |
| -.. code-block:: rst |
63 | 45 |
|
64 |
| - .. src-trace:: dcdc charge |
65 |
| - :project: dcdc |
66 |
| - :directory: ./discharge |
| 46 | +Example |
| 47 | +------- |
67 | 48 |
|
68 |
| -The needs defined in source code are extracted and rendered to: |
| 49 | +.. src-trace:: dummy src |
| 50 | + :project: src |
69 | 51 |
|
70 |
| -.. src-trace:: dcdc charge |
71 |
| - :project: dcdc |
72 |
| - :directory: ./discharge |
| 52 | +.. note:: **local-url** is not working on the website as it only supports local browse |
73 | 53 |
|
74 |
| -To have a more customized configuration of ``CodeLinks``, please refer to :ref:`configuration <configuration>`. |
| 54 | +Section :ref:`Directive <directive>` provides more adavanced usage. |
0 commit comments