Skip to content

Commit bc423a4

Browse files
authored
Migrate codelinks config into ubproject.toml (#32)
Consolidate the source-tracing config into the single ubproject.toml so ubCode and sphinx-codelinks read from the same place, and add the ubproject.redirect.toml in src/ introduced in ubCode 0.29.0b1 so the language server can resolve the project config when editing source files outside the docs folder. Drop the parse.ignore_directives suppression for src-trace and the 'ubCode is not aware' limitation note now that codelinks support has landed in ubCode.
1 parent 3a5be63 commit bc423a4

5 files changed

Lines changed: 44 additions & 55 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
},
6464
}
6565

66-
src_trace_config_from_toml = "src_trace.toml"
66+
src_trace_config_from_toml = "ubproject.toml"
6767

6868
###############################################################################
6969
# SPHINX-NEEDS Config END

docs/how-to-guides/trace-code/index.rst

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ Follow the installation instructions in the `CodeLinks documentation <https://co
1212

1313
**Step 2: Configure CodeLinks**
1414

15-
Create a file named ``src_trace.toml`` in your ``docs`` folder (next
16-
to ``conf.py``) with the following content:
15+
Add a ``[codelinks]`` section to your ``ubproject.toml`` (next to
16+
``conf.py``) with the following content:
1717

18-
.. literalinclude:: ../../src_trace.toml
18+
.. literalinclude:: ../../ubproject.toml
1919
:language: toml
20-
:caption: src_trace.toml
20+
:caption: ubproject.toml (codelinks section)
21+
:start-at: "[codelinks]"
2122

2223
**Step 3: Add the src-trace Directive**
2324

@@ -78,11 +79,3 @@ Finally you can link from/to the traced source code lines like this:
7879

7980
This is a requirement that links to a need that has traced source code
8081
lines.
81-
82-
.. note::
83-
84-
Current limitation: ``ubCode`` is not aware of this need id yet. This
85-
means that the ``ubCode`` navigation inside Visual Studio Code will
86-
not work and jumping from this ``rst`` file to the source code line
87-
will not work. This will be implemented and supported in a future
88-
release.

docs/src_trace.toml

Lines changed: 0 additions & 36 deletions
This file was deleted.

docs/ubproject.toml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ name = "X-as-Code (XaC)"
1313
description = "Showcases for working with Sphinx-Needs"
1414
srcdir = "."
1515

16-
[parse]
17-
ignore_directives = [
18-
# src-trace is not recognized by ubcode and produces a warning lint.
19-
"src-trace"
20-
]
21-
2216
# Rules for the ubCode formater, to get a nice looking documentation.
2317
[format_rst]
2418
fail_on_warning = []
@@ -408,3 +402,40 @@ src = "."
408402
# ubCode setting: run a script command
409403
[scripts]
410404
sphinx = "sphinx-build -b html . _build/html"
405+
406+
[codelinks]
407+
# Configuration for source tracing
408+
set_local_url = false # Set to true to enable local code html and URL generation
409+
local_url_field = "local" # Need's field name for local URL
410+
set_remote_url = true # Set to true to enable remote url to be generated
411+
remote_url_field = "remote-url" # Need's field name for remote URL
412+
413+
414+
[codelinks.projects.x-as-code-cpp]
415+
remote_url_pattern = "https://github.com/useblocks/x-as-code/blob/{commit}/{path}#L{line}" # URL pattern for remote source code
416+
417+
[codelinks.projects.x-as-code-cpp.source_discover]
418+
src_dir = "../src" # Relative path from this TOML config to the source directory
419+
include = [
420+
"*.cpp",
421+
"*.h"
422+
]
423+
exclude=[]
424+
gitignore = true
425+
comment_type = "cpp"
426+
427+
[codelinks.projects.x-as-code-cpp.analyse]
428+
get_need_id_refs = true
429+
get_oneline_needs = true
430+
get_rst = true
431+
432+
[codelinks.projects.x-as-code-cpp.analyse.oneline_comment_style]
433+
# start_sequence = "@"
434+
# end_sequence for the online comments; default is an os-dependant newline character
435+
field_split_char = ","
436+
needs_fields = [
437+
{ "name" = "title", "type" = "str" },
438+
{ "name" = "id", "type" = "str" },
439+
{ "name" = "type", "type" = "str", "default" = "impl" },
440+
{ "name" = "links", "type" = "list[str]", "default" = [] },
441+
]

src/ubproject.redirect.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
path = "../docs"

0 commit comments

Comments
 (0)