Skip to content

Commit cb8b641

Browse files
authored
Merge pull request #2551 from DeusData/feat/doc-links-documents
feat(doc-links): Markdown, ADR, reST, AsciiDoc and PDF sections link to the code they name
2 parents ec6f837 + cb24c41 commit cb8b641

57 files changed

Lines changed: 28357 additions & 75 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Makefile.cbm‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,17 @@ EXTRACTION_SRCS = \
375375
$(CBM_DIR)/extract_dbt.c \
376376
$(CBM_DIR)/doclink.c \
377377
$(CBM_DIR)/doclink_cs.c \
378+
$(CBM_DIR)/doclink_md.c \
379+
$(CBM_DIR)/doclink_rst.c \
380+
$(CBM_DIR)/doclink_py.c \
381+
$(CBM_DIR)/doc_adr.c \
382+
$(CBM_DIR)/doc_pdf.c \
383+
$(CBM_DIR)/doc_adoc.c \
384+
$(CBM_DIR)/pdf/pdf_obj.c \
385+
$(CBM_DIR)/pdf/pdf_font.c \
386+
$(CBM_DIR)/pdf/pdf_text.c \
387+
$(CBM_DIR)/pdf/pdf_tables.c \
388+
$(CBM_DIR)/pdf/pdf_unicode.c \
378389
$(CBM_DIR)/sql_values.c \
379390
$(CBM_DIR)/helpers.c \
380391
$(CBM_DIR)/cpp_branch_views.c \
@@ -497,6 +508,10 @@ PIPELINE_SRCS = \
497508
src/pipeline/pass_doclinks.c \
498509
src/pipeline/doc_links.c \
499510
src/pipeline/doc_links_cs.c \
511+
src/pipeline/doc_links_md.c \
512+
src/pipeline/doc_links_pdf.c \
513+
src/pipeline/doc_links_rst.c \
514+
src/pipeline/doc_links_adoc.c \
500515
src/pipeline/doc_links_msbuild.c \
501516
src/pipeline/pass_route_nodes.c \
502517
src/pipeline/pass_enrichment.c \
@@ -759,7 +774,7 @@ TEST_DISCOVER_SRCS = \
759774

760775
TEST_GRAPH_BUFFER_SRCS = tests/test_graph_buffer.c
761776

762-
TEST_PIPELINE_SRCS = tests/test_registry.c tests/test_pipeline.c tests/test_pipeline_conventions.c tests/test_pipeline_frozen.c tests/test_importance.c tests/test_cross_repo.c tests/test_fqn.c tests/test_route_canon.c tests/test_path_alias.c tests/test_configlink.c tests/test_doclinks.c tests/test_doc_mentions.c tests/test_infrascan.c tests/test_worker_pool.c tests/test_parallel.c tests/test_index_resilience.c tests/test_index_format.c tests/test_call_reference_contract.c tests/repro/repro_call_scope_usages.c tests/repro/repro_call_argument_usages.c tests/repro/repro_reference_precision.c tests/repro/repro_lexical_binding_precision.c tests/repro/repro_call_argument_matrix_a.c tests/repro/repro_call_argument_matrix_b.c tests/repro/repro_call_node_behaviors.c tests/repro/repro_language_registry.c tests/repro/repro_call_node_manifest.c tests/repro/repro_lsp_ordered_signatures.c tests/repro/repro_lsp_ordered_local.c tests/repro/repro_ts_overload_return_chains.c tests/repro/repro_harness_cleanup.c tests/repro/repro_runner_filter.c
777+
TEST_PIPELINE_SRCS = tests/test_registry.c tests/test_pipeline.c tests/test_pipeline_conventions.c tests/test_pipeline_frozen.c tests/test_importance.c tests/test_cross_repo.c tests/test_fqn.c tests/test_route_canon.c tests/test_path_alias.c tests/test_configlink.c tests/test_doclinks.c tests/test_doc_mentions.c tests/test_doc_links_md.c tests/test_doc_links_pdf.c tests/test_doc_links_rst.c tests/test_doc_links_adoc.c tests/test_infrascan.c tests/test_worker_pool.c tests/test_parallel.c tests/test_index_resilience.c tests/test_index_format.c tests/test_call_reference_contract.c tests/repro/repro_call_scope_usages.c tests/repro/repro_call_argument_usages.c tests/repro/repro_reference_precision.c tests/repro/repro_lexical_binding_precision.c tests/repro/repro_call_argument_matrix_a.c tests/repro/repro_call_argument_matrix_b.c tests/repro/repro_call_node_behaviors.c tests/repro/repro_language_registry.c tests/repro/repro_call_node_manifest.c tests/repro/repro_lsp_ordered_signatures.c tests/repro/repro_lsp_ordered_local.c tests/repro/repro_ts_overload_return_chains.c tests/repro/repro_harness_cleanup.c tests/repro/repro_runner_filter.c
763778

764779
TEST_WATCHER_SRCS = tests/test_watcher.c
765780

‎THIRD_PARTY.md‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,109 @@ Semantic vector search uses static token embeddings derived from the
138138
See `vendored/nomic/NOTICE` for the exact derivation procedure
139139
(per-token inference + int8 quantization via `scripts/extract_nomic_vectors.py`).
140140

141+
## Embedded Character Data (PDF text layer)
142+
143+
The PDF text-layer extractor (`internal/cbm/pdf/`) carries static tables
144+
derived from the following sources. No upstream source code is included.
145+
146+
- **Adobe Glyph List** — the glyph-name subset in `internal/cbm/pdf/pdf_tables.c`
147+
(the names of the standard Latin encodings and common symbols, mapped to
148+
Unicode) follows [adobe-type-tools/agl-aglfn](https://github.com/adobe-type-tools/agl-aglfn)
149+
`glyphlist.txt`.
150+
- **License:** BSD-3-Clause
151+
- **Copyright:** Copyright 2002-2019 Adobe (http://www.adobe.com/).
152+
- **Adobe core-14 font metrics** — the advance widths of the printable ASCII
153+
range of Helvetica and Times-Roman in `pdf_tables.c` (used only for a
154+
standard-14 font that omits its `/Widths`) are the values of Adobe's
155+
core-14 AFM files. The AFM files themselves are not distributed.
156+
- **Copyright:** Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems
157+
Incorporated. All Rights Reserved.
158+
- **Unicode Character Database** — `internal/cbm/pdf/pdf_unicode.c` (NFKC of
159+
each code point, canonical compositions, character classes) is generated
160+
by `scripts/gen-pdf-unicode.py` from CPython's `unicodedata` (Unicode
161+
16.0.0).
162+
- **License:** Unicode License v3 (text below)
163+
- **Copyright:** Copyright © 1991-2026 Unicode, Inc.
164+
- The base encodings (Standard, WinAnsi, MacRoman, Symbol) are those of
165+
ISO 32000-1, Annex D.
166+
167+
Adobe Glyph List license (BSD-3-Clause):
168+
169+
```
170+
Copyright 2002-2019 Adobe (http://www.adobe.com/).
171+
172+
Redistribution and use in source and binary forms, with or without
173+
modification, are permitted provided that the following conditions are
174+
met:
175+
176+
Redistributions of source code must retain the above copyright notice,
177+
this list of conditions and the following disclaimer.
178+
179+
Redistributions in binary form must reproduce the above copyright
180+
notice, this list of conditions and the following disclaimer in the
181+
documentation and/or other materials provided with the distribution.
182+
183+
Neither the name of Adobe nor the names of its contributors may be
184+
used to endorse or promote products derived from this software without
185+
specific prior written permission.
186+
187+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
188+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
189+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
190+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
191+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
192+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
193+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
194+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
195+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
196+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
197+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
198+
```
199+
200+
Unicode License v3:
201+
202+
```
203+
UNICODE LICENSE V3
204+
205+
COPYRIGHT AND PERMISSION NOTICE
206+
207+
Copyright © 1991-2026 Unicode, Inc.
208+
209+
NOTICE TO USER: Carefully read the following legal agreement. BY
210+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
211+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
212+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
213+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
214+
215+
Permission is hereby granted, free of charge, to any person obtaining a
216+
copy of data files and any associated documentation (the "Data Files") or
217+
software and any associated documentation (the "Software") to deal in the
218+
Data Files or Software without restriction, including without limitation
219+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
220+
copies of the Data Files or Software, and to permit persons to whom the
221+
Data Files or Software are furnished to do so, provided that either (a)
222+
this copyright and permission notice appear with all copies of the Data
223+
Files or Software, or (b) this copyright and permission notice appear in
224+
associated Documentation.
225+
226+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
227+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
228+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
229+
THIRD PARTY RIGHTS.
230+
231+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
232+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
233+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
234+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
235+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
236+
FILES OR SOFTWARE.
237+
238+
Except as contained in this notice, the name of a copyright holder shall
239+
not be used in advertising or otherwise to promote the sale, use or other
240+
dealings in these Data Files or Software without prior written
241+
authorization of the copyright holder.
242+
```
243+
141244
## Hybrid LSP — Reference Language Servers
142245

143246
The Hybrid LSP layer (`internal/cbm/lsp/`) is an original C implementation

‎internal/cbm/cbm.c‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,6 +2802,45 @@ static CBMFileResult *extract_file_ex_body(const char *source, int source_len, C
28022802
cbm_test_fault_inject(rel_path);
28032803
#endif
28042804

2805+
/* A PDF has no grammar: its text layer is read directly, a Section per
2806+
* page plus the pages' code mentions (doc_pdf.c). */
2807+
if (language == CBM_LANG_PDF) {
2808+
result->module_qn = cbm_fqn_module_source_lang(a, project, rel_path, language);
2809+
CBMExtractCtx pdf_ctx = {
2810+
.arena = a,
2811+
.scratch = scratch,
2812+
.result = result,
2813+
.source = source,
2814+
.source_len = source_len,
2815+
.language = language,
2816+
.project = project,
2817+
.rel_path = rel_path,
2818+
.module_qn = result->module_qn,
2819+
};
2820+
cbm_pdf_extract_document(&pdf_ctx);
2821+
cbm_index_mark_done(rel_path);
2822+
return result;
2823+
}
2824+
/* AsciiDoc has no grammar either: its headings, includes, attribute
2825+
* references and monospace spans are read from the text (doc_adoc.c). */
2826+
if (language == CBM_LANG_ASCIIDOC) {
2827+
result->module_qn = cbm_fqn_module_source_lang(a, project, rel_path, language);
2828+
CBMExtractCtx adoc_ctx = {
2829+
.arena = a,
2830+
.scratch = scratch,
2831+
.result = result,
2832+
.source = source,
2833+
.source_len = source_len,
2834+
.language = language,
2835+
.project = project,
2836+
.rel_path = rel_path,
2837+
.module_qn = result->module_qn,
2838+
};
2839+
cbm_adoc_extract_document(&adoc_ctx);
2840+
cbm_index_mark_done(rel_path);
2841+
return result;
2842+
}
2843+
28052844
// Get language spec
28062845
const CBMLangSpec *spec = cbm_lang_spec(language);
28072846
if (!spec) {

‎internal/cbm/cbm.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ typedef enum {
209209
CBM_LANG_ARKTS, // ArkTS (HarmonyOS/OpenHarmony .ets — TypeScript superset + ArkUI)
210210
CBM_LANG_PLSQL, // Oracle PL/SQL
211211
CBM_LANG_CHIALISP, // Chialisp (.clsp/.clib/.clinc — Chia smart-coin s-expression language)
212+
CBM_LANG_PDF, // PDF documents: the text layer, read without a grammar (doc_pdf.c)
213+
CBM_LANG_ASCIIDOC, // AsciiDoc documents, read without a grammar (doc_adoc.c)
212214
CBM_LANG_COUNT
213215
} CBMLanguage;
214216

@@ -292,6 +294,12 @@ typedef struct {
292294
* are bound to the owning result's source identity before cross-file use. */
293295
uint32_t test_name_start_byte, test_name_end_byte;
294296
uint32_t test_body_start_byte, test_body_end_byte;
297+
/* Documents only: facts a document definition adds to its node's
298+
* properties, as a NULL-terminated key, value, key, value, ... list (an
299+
* ADR's id, status, date, deciders, title). Keys are fixed literals; the
300+
* values are escaped where the properties are written. Tail field:
301+
* zero-init stays valid. */
302+
const char **extra_props;
295303
} CBMDefinition;
296304

297305
/* Argument captured from a call expression */

0 commit comments

Comments
 (0)