docbridge 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md CHANGED
@@ -63,7 +63,7 @@ with the specification for the interface whose exact contract you need:
63
63
  - [Commit messages](contributing/commits.md)
64
64
  - [Pull requests](contributing/pull-requests.md)
65
65
  - [Releasing](contributing/releasing.md)
66
- - [Self-audit baseline](contributing/self-audit.md)
66
+ - [Self-audit](contributing/self-audit.md)
67
67
 
68
68
  ## Historical records
69
69
 
@@ -57,22 +57,23 @@ source file may match only one language.
57
57
 
58
58
  ## Languages
59
59
 
60
- | Key | Files | `visibility` values | Default | Scanner |
61
- | ------------ | ---------------------------------------------------- | -------------------------------- | --------------------- | ------------------------- |
62
- | `typescript` | `.ts`, `.tsx`, `.mts`, `.cts`, not declaration files | `public`, `protected`, `private` | `public`, `protected` | built in |
63
- | `javascript` | `.js`, `.jsx`, `.mjs`, `.cjs` | `public`, `protected`, `private` | `public`, `protected` | built in |
64
- | `swift` | `.swift` | `public`, `open`, `internal` | `public`, `open` | `docbridge-swift-scanner` |
65
- | `dart` | `.dart` | `public` | `public` | `docbridge_dart_scanner` |
66
- | `rust` | `.rs` | `pub`, `private` | `pub` | `docbridge-rust-scanner` |
67
- | `go` | `.go` | `exported`, `unexported` | `exported` | `docbridge-go-scanner` |
68
- | `python` | `.py` | `public`, `private` | `public` | CPython 3.10 or later |
69
- | `ruby` | `.rb` | `public`, `protected`, `private` | `public` | CRuby 3.3 or later |
60
+ | Key | Files | `visibility` values | Default | Scanner |
61
+ | ------------ | ---------------------------------------------------- | ------------------------------------------- | --------------------- | ------------------------- |
62
+ | `typescript` | `.ts`, `.tsx`, `.mts`, `.cts`, not declaration files | `public`, `protected`, `private` | `public`, `protected` | built in |
63
+ | `javascript` | `.js`, `.jsx`, `.mjs`, `.cjs` | `public`, `protected`, `private` | `public`, `protected` | built in |
64
+ | `swift` | `.swift` | `public`, `open`, `internal` | `public`, `open` | `docbridge-swift-scanner` |
65
+ | `dart` | `.dart` | `public` | `public` | `docbridge_dart_scanner` |
66
+ | `rust` | `.rs` | `pub`, `private` | `pub` | `docbridge-rust-scanner` |
67
+ | `go` | `.go` | `exported`, `unexported` | `exported` | `docbridge-go-scanner` |
68
+ | `python` | `.py` | `public`, `private` | `public` | CPython 3.10 or later |
69
+ | `ruby` | `.rb` | `public`, `protected`, `private` | `public` | CRuby 3.3 or later |
70
+ | `java` | `.java` | `public`, `protected`, `package`, `private` | `public` | JDK 17 or later |
70
71
 
71
72
  Patterns must end with one of the language's extensions. The npm package
72
73
  bundles the Swift, Dart, Rust, and Go scanners for `darwin-arm64` and
73
74
  `linux-x64`; TypeScript, JavaScript, and Markdown need no scanner binary.
74
- Python and Ruby are scanned by scripts in the package that run on the
75
- interpreter installed on the machine, on any platform; see
75
+ Python, Ruby, and Java are scanned by workers in the package that run on the
76
+ interpreter or JDK installed on the machine, on any platform; see
76
77
  [Scanner runtimes](#scanner-runtimes).
77
78
 
78
79
  Each language accepts an optional `visibility` array; omitting it uses the
@@ -81,11 +82,12 @@ type members; top-level declarations must be exported, and every JavaScript
81
82
  member is `public`. Rust `pub` means unrestricted `pub`, and `private` covers
82
83
  every narrower visibility. A declaration excluded by visibility is not an
83
84
  endpoint. An `@doc` on an excluded TypeScript or JavaScript member, or on an
84
- excluded Python or Ruby declaration, is `unsupported_declaration`; the Swift,
85
+ excluded Python, Ruby, or Java declaration, is `unsupported_declaration`; the Swift,
85
86
  Dart, Rust, and Go scanners ignore an `@doc` on an excluded declaration
86
87
  without a diagnostic. See `docbridge docs show linking` for the per-language
87
88
  declaration rules, including Dart's and Python's leading-underscore privacy,
88
- Go's exported-name rule for methods, and Ruby's `private` calls. The
89
+ Go's exported-name rule for methods, Ruby's `private` calls, and Java's
90
+ implicitly public interface members. The
89
91
  [Scanning specification](https://github.com/salan70/docbridge/blob/main/docs/specs/scanning.md)
90
92
  owns the exact scanner behavior and platform keys.
91
93
 
@@ -93,13 +95,15 @@ owns the exact scanner behavior and platform keys.
93
95
 
94
96
  ## Scanner runtimes
95
97
 
96
- Python and Ruby files are scanned by scripts that run on an interpreter
97
- installed on the machine: CPython 3.10 or later, and CRuby 3.3 or later, whose
98
- bundled Prism parses the source. DocBridge looks for `python3`, then `python`
99
- (`py -3`, then `python` on Windows), and for `ruby` on `PATH`, and checks each
100
- candidate before using it. The scripts never import or run project code.
98
+ Python, Ruby, and Java files are scanned by workers that run on a runtime
99
+ installed on the machine: CPython 3.10 or later; CRuby 3.3 or later, whose
100
+ bundled Prism parses the source; and a JDK 17 or later, whose `jdk.compiler`
101
+ module parses the source. A JRE lacks that module and cannot scan Java.
102
+ DocBridge looks for `python3`, then `python` (`py -3`, then `python` on
103
+ Windows), for `ruby`, and for `java` on `PATH`, and checks each candidate
104
+ before using it. The workers never import, compile, or run project code.
101
105
 
102
- To use another interpreter, name it under `scanners`:
106
+ To use another runtime, name it under `scanners`:
103
107
 
104
108
  ```json
105
109
  {
@@ -113,13 +117,15 @@ To use another interpreter, name it under `scanners`:
113
117
  }
114
118
  ```
115
119
 
116
- `command` is the interpreter followed by its own arguments, as an array rather
117
- than a shell string; a relative path resolves against the project root.
118
- Without a configured command, the environment variable
119
- `DOCBRIDGE_PYTHON_RUNTIME` or `DOCBRIDGE_RUBY_RUNTIME` can name one
120
- interpreter executable instead. A configured command or variable is the only
121
- interpreter tried: when it is missing or unusable, the files report
122
- `code_scanner_unavailable` instead of falling back to `PATH`.
120
+ `command` is the runtime executable followed by its own arguments, as an
121
+ array rather than a shell string; a relative path resolves against the project
122
+ root. A Java entry names the JDK's `java`, such as
123
+ `["/opt/jdk-21/bin/java"]`. Without a configured command, the environment
124
+ variable `DOCBRIDGE_PYTHON_RUNTIME`, `DOCBRIDGE_RUBY_RUNTIME`, or
125
+ `DOCBRIDGE_JAVA_RUNTIME` can name one runtime executable instead. A configured
126
+ command or variable is the only runtime tried: when it is missing or unusable,
127
+ the files report `code_scanner_unavailable` instead of falling back to
128
+ `PATH`.
123
129
 
124
130
  A configured command runs with your permissions in the CLI and in the editor
125
131
  extension. Review `scanners` in a repository you do not trust before running
@@ -148,9 +154,10 @@ documentation should stay outside the graph:
148
154
  ```
149
155
 
150
156
  For Go, `cmd/**/*.go` and `internal/**/*.go` scan fewer files than
151
- `**/*.go`, but `_test.go` files under them are still scanned. For Python and
152
- Ruby, keep test directories such as `tests/` and `spec/` outside the patterns
153
- in the same way.
157
+ `**/*.go`, but `_test.go` files under them are still scanned. For Python,
158
+ Ruby, and Java, keep test directories such as `tests/`, `spec/`, and
159
+ `src/test/` outside the patterns in the same way; in a Maven or Gradle layout,
160
+ `src/main/java/**/*.java` does.
154
161
 
155
162
  DocBridge always ignores dependency directories, Git metadata, dot-prefixed
156
163
  path segments, symbolic links, and TypeScript declaration files (`.d.ts`,
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Set up DocBridge in an existing TypeScript, JavaScript, Swift, Dart, Rust, Go, Python, or Ruby project.
2
+ description: Set up DocBridge in an existing TypeScript, JavaScript, Swift, Dart, Rust, Go, Python, Ruby, or Java project.
3
3
  ---
4
4
 
5
5
  # Getting Started
@@ -106,8 +106,13 @@ def login(email: str, password: str) -> None:
106
106
  def login(email, password); end
107
107
  ```
108
108
 
109
+ ```java
110
+ /** @doc docs/auth.md#login-flow */
111
+ public void login(String email, char[] password) {}
112
+ ```
113
+
109
114
  Paths are relative to the configured root. An annotation on an unsupported
110
- declaration, or on a TypeScript, JavaScript, Python, or Ruby declaration
115
+ declaration, or on a TypeScript, JavaScript, Python, Ruby, or Java declaration
111
116
  excluded by visibility, produces `unsupported_declaration`; the same
112
117
  declaration without an annotation is ignored. Swift, Dart, Rust, and Go ignore
113
118
  an annotation on a declaration excluded by visibility without a diagnostic. To link such a declaration, add
@@ -209,6 +214,28 @@ file is one endpoint. Bare `private`, `protected`, and `public` calls,
209
214
  modules, and constants are always `public`. `attr_reader` and its siblings,
210
215
  `alias`, and `define_method` are not endpoints.
211
216
 
217
+ ### Java declarations
218
+
219
+ Supported forms are top-level and nested classes, interfaces, enums, records,
220
+ and annotation types; methods and constructors; and fields and enum
221
+ constants. Put `@doc` in the declaration's Javadoc comment (`/** */`); `//`
222
+ and `/* */` comments are ignored. IDs are dot-qualified without the package,
223
+ and methods and constructors add their parameter types: `AuthService`,
224
+ `AuthService.MAX_ATTEMPTS`, `AuthService.login(String,char[])`, and
225
+ `AuthService.AuthService(Authenticator)` for a constructor. Parameter types
226
+ are written as in the source, without type arguments or annotations, and
227
+ varargs become arrays (`String...` is `String[]`). Visibility defaults to
228
+ `public`. Interface members without a modifier and enum constants are
229
+ `public`, and a member is never more visible than its enclosing types. Local
230
+ and anonymous classes, lambdas, and initializer blocks are not endpoints. An
231
+ `@doc` above a field statement that declares several names (`int a, b;`) is
232
+ `unsupported_declaration` because it cannot name one endpoint; link those
233
+ fields from `docbridge.links.json` instead.
234
+
235
+ `javadoc` reports `@doc` as an unknown tag when doclint runs with
236
+ `-Xdoclint`. Register the tag with `-tag doc:a:"DocBridge:"` so the check
237
+ accepts it.
238
+
212
239
  <!-- @code src/scan/markdown/markdown.ts#scanMarkdown -->
213
240
 
214
241
  ## Documentation to code
@@ -36,15 +36,18 @@ lacks a binary for the current platform or the binary cannot execute.
36
36
  Reinstall the package first. If the platform is not supported, run DocBridge
37
37
  in a supported environment or build the scanner from the repository.
38
38
 
39
- Python and Ruby run on the interpreter installed on the machine. For them,
40
- `code_scanner_unavailable` names the interpreter DocBridge needs, the minimum
41
- version, and what it found for each candidate: no interpreter on `PATH`, a
42
- version below CPython 3.10 or CRuby 3.3, or a Ruby whose bundled Prism does not
43
- load. Install a supported version on `PATH`, or point `scanners.python.command`
44
- or `scanners.ruby.command` in the configuration, or `DOCBRIDGE_PYTHON_RUNTIME`
45
- or `DOCBRIDGE_RUBY_RUNTIME` in the environment, at one; see
46
- [Configuration](configuration.md#scanner-runtimes). When the message names
47
- one of those overrides, DocBridge tried only that interpreter, so fix or remove
39
+ Python, Ruby, and Java run on the runtime installed on the machine. For them,
40
+ `code_scanner_unavailable` names the runtime DocBridge needs, the minimum
41
+ version, and what it found for each candidate: no runtime on `PATH`, a
42
+ version below CPython 3.10, CRuby 3.3, or JDK 17, a Ruby whose bundled Prism
43
+ does not load, or a Java runtime without the `jdk.compiler` module, which is
44
+ what a JRE or a trimmed `jlink` image reports. Install a supported version on
45
+ `PATH`, or point `scanners.<language>.command` in the configuration, or
46
+ `DOCBRIDGE_PYTHON_RUNTIME`, `DOCBRIDGE_RUBY_RUNTIME`, or
47
+ `DOCBRIDGE_JAVA_RUNTIME` in the environment, at one; see
48
+ [Configuration](configuration.md#scanner-runtimes). For Java, that is the
49
+ `java` executable of a full JDK 17 or later, not a JRE. When the message names
50
+ one of those overrides, DocBridge tried only that runtime, so fix or remove
48
51
  the override instead of installing another one.
49
52
 
50
53
  `code_scanner_failed` diagnostics contain the worker failure rather than
@@ -54,9 +57,10 @@ Check that the source parses with the project's own toolchain, then reproduce
54
57
  with the smallest configured file set.
55
58
 
56
59
  `code_parse_error` means a TypeScript, JavaScript, Swift, Dart, Rust, Go,
57
- Python, or Ruby source file has a syntax error. The diagnostic points at the
58
- first error the language's parser found and includes the parser's message; for
59
- Python and Ruby, the wording comes from the installed interpreter. DocBridge extracts no links or symbols
60
+ Python, Ruby, or Java source file has a syntax error. The diagnostic points at
61
+ the first error the language's parser found and includes the parser's message;
62
+ for Python, Ruby, and Java, the wording comes from the installed runtime, and
63
+ Java syntax newer than the installed JDK does not parse. DocBridge extracts no links or symbols
60
64
  from that file, so fix the syntax before judging link diagnostics that involve
61
65
  it. Unlike
62
66
  `code_scanner_failed`, the worker ran correctly; the source itself did not
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docbridge",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "A CLI that links Markdown specifications and code declarations. Runs on Node.js and Bun.",
5
5
  "keywords": [
6
6
  "bun",
@@ -35,7 +35,17 @@
35
35
  },
36
36
  "language": {
37
37
  "type": "string",
38
- "enum": ["typescript", "swift", "dart", "rust", "go", "javascript", "python", "ruby"],
38
+ "enum": [
39
+ "typescript",
40
+ "swift",
41
+ "dart",
42
+ "rust",
43
+ "go",
44
+ "javascript",
45
+ "python",
46
+ "ruby",
47
+ "java"
48
+ ],
39
49
  "description": "Code language for code context blocks."
40
50
  },
41
51
  "startLine": {
@@ -25,7 +25,8 @@
25
25
  "go": { "$ref": "#/$defs/goEntry" },
26
26
  "javascript": { "$ref": "#/$defs/javascriptEntry" },
27
27
  "python": { "$ref": "#/$defs/pythonEntry" },
28
- "ruby": { "$ref": "#/$defs/rubyEntry" }
28
+ "ruby": { "$ref": "#/$defs/rubyEntry" },
29
+ "java": { "$ref": "#/$defs/javaEntry" }
29
30
  }
30
31
  },
31
32
  "docs": {
@@ -239,6 +240,28 @@
239
240
  }
240
241
  }
241
242
  }
243
+ },
244
+ "javaEntry": {
245
+ "type": "object",
246
+ "additionalProperties": false,
247
+ "required": ["patterns"],
248
+ "properties": {
249
+ "patterns": {
250
+ "type": "array",
251
+ "minItems": 1,
252
+ "items": {
253
+ "type": "string",
254
+ "pattern": "\\.java$"
255
+ }
256
+ },
257
+ "visibility": {
258
+ "type": "array",
259
+ "items": {
260
+ "type": "string",
261
+ "enum": ["public", "protected", "package", "private"]
262
+ }
263
+ }
264
+ }
242
265
  }
243
266
  }
244
267
  }
@@ -31,7 +31,17 @@
31
31
  },
32
32
  "language": {
33
33
  "type": "string",
34
- "enum": ["typescript", "swift", "dart", "rust", "go", "javascript", "python", "ruby"],
34
+ "enum": [
35
+ "typescript",
36
+ "swift",
37
+ "dart",
38
+ "rust",
39
+ "go",
40
+ "javascript",
41
+ "python",
42
+ "ruby",
43
+ "java"
44
+ ],
35
45
  "description": "Code language for code nodes."
36
46
  },
37
47
  "location": { "$ref": "common-output.schema.json#/$defs/location" },