diff --git a/docs/source/components/features.rst b/docs/source/components/features.rst index cd089db..0fd9811 100644 --- a/docs/source/components/features.rst +++ b/docs/source/components/features.rst @@ -81,6 +81,30 @@ Features .. fault:: Sphinx-codelinks halucinates traceability objects in C++ :id: FAULT_CPP_2 +.. feature:: C# Language Support + :id: FE_CSHARP + + Support for defining traceability objects in C# source code. + + The C# language parser leverages tree-sitter to accurately identify and extract + comments from C# source files, including single-line (``//``), multi-line (``/* */``), + and documentation (``///``) comment styles. This ensures that traceability markers are + correctly associated with the appropriate code structures such as classes, methods, and + properties. + + Key capabilities: + + * Detection of inline, block, and documentation comments + * Association of comments with method, class, and property declarations + * Support for standard C# comment conventions + * Accurate scope detection for nested structures + + .. fault:: Traceability objects are not detected in C# language + :id: FAULT_CSHARP_1 + + .. fault:: Sphinx-codelinks halucinates traceability objects in C# + :id: FAULT_CSHARP_2 + .. feature:: Python Language Support :id: FE_PY diff --git a/docs/source/development/change_log.rst b/docs/source/development/change_log.rst index b34724f..d0ab1cc 100644 --- a/docs/source/development/change_log.rst +++ b/docs/source/development/change_log.rst @@ -7,6 +7,8 @@ Upcoming -------- - โฌ†๏ธ Support and test sphinx-needs v5-8 +- ๐Ÿ“š Documented C# language support in ``features.rst`` +- ๐Ÿงช Added Sphinx integration test for C# source files - โœจ Added Go parser for the ``analyse`` module. Need ID references and one-line need definitions can now be extracted from Go source files. @@ -35,7 +37,6 @@ New and Improved Warning messages now include more context to help diagnose parsing issues. - ๐Ÿ“š Added traceability page to the documentation. - - ๐Ÿ“š Added ``features.rst`` page documenting the full feature set with source tracing. Fixes @@ -45,7 +46,6 @@ Fixes Leading and trailing spaces in extracted marker content are now correctly stripped. - .. _`release:1.1.0`: 1.1.0 diff --git a/tests/__snapshots__/test_src_trace/test_build_html[sphinx_project5-source_code5].doctree.xml b/tests/__snapshots__/test_src_trace/test_build_html[sphinx_project5-source_code5].doctree.xml new file mode 100644 index 0000000..c3361fa --- /dev/null +++ b/tests/__snapshots__/test_src_trace/test_build_html[sphinx_project5-source_code5].doctree.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/doc_test/cs_basic/conf.py b/tests/doc_test/cs_basic/conf.py new file mode 100644 index 0000000..d67a5bb --- /dev/null +++ b/tests/doc_test/cs_basic/conf.py @@ -0,0 +1,27 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = "source-tracing-demo" +copyright = "2025, useblocks" +author = "useblocks" + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = ["sphinx_needs", "sphinx_codelinks"] + +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +src_trace_config_from_toml = "src_trace.toml" + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "alabaster" +html_static_path = ["_static"] diff --git a/tests/doc_test/cs_basic/dummy_src.cs b/tests/doc_test/cs_basic/dummy_src.cs new file mode 100644 index 0000000..4e3d3a3 --- /dev/null +++ b/tests/doc_test/cs_basic/dummy_src.cs @@ -0,0 +1,7 @@ +using System; + +// @ title here, IMPL_1, impl +void SingleLineExample() +{ + Console.WriteLine("Single-line comment example"); +} diff --git a/tests/doc_test/cs_basic/index.rst b/tests/doc_test/cs_basic/index.rst new file mode 100644 index 0000000..1750ff7 --- /dev/null +++ b/tests/doc_test/cs_basic/index.rst @@ -0,0 +1,2 @@ +.. src-trace:: + :project: src diff --git a/tests/doc_test/cs_basic/src_trace.toml b/tests/doc_test/cs_basic/src_trace.toml new file mode 100644 index 0000000..fd2a091 --- /dev/null +++ b/tests/doc_test/cs_basic/src_trace.toml @@ -0,0 +1,5 @@ +[codelinks.projects.src] +remote_url_pattern = "https://github.com/useblocks/sphinx-codelinks/blob/{commit}/{path}#L{line}" + +[codelinks.projects.src.source_discover] +comment_type = "cs" diff --git a/tests/test_src_trace.py b/tests/test_src_trace.py index 329db25..abaa0c1 100644 --- a/tests/test_src_trace.py +++ b/tests/test_src_trace.py @@ -193,6 +193,10 @@ def test_src_tracing_config_positive(make_app: Callable[..., SphinxTestApp], tmp Path("doc_test") / "id_required", Path("doc_test") / "id_required", ), + ( + Path("doc_test") / "cs_basic", + Path("doc_test") / "cs_basic", + ), ( Path("doc_test") / "go_basic", Path("doc_test") / "go_basic",