zard 0.0.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +27 -0
- data/CONTEXT.md +93 -0
- data/LICENSE +373 -0
- data/README.md +170 -0
- data/docs/adr/0001-contract-and-documentation-channels.md +13 -0
- data/docs/adr/0002-em-dash-zard-documentation-marker.md +29 -0
- data/docs/adr/0003-package-boundaries-and-rigor-lens.md +15 -0
- data/docs/agents/domain.md +15 -0
- data/docs/agents/issue-tracker.md +22 -0
- data/docs/agents/triage-labels.md +11 -0
- data/docs/supported-ruby-syntax.md +55 -0
- data/docs/usage.md +124 -0
- data/examples/catalog/expected.md +51 -0
- data/examples/catalog/lib/catalog/entry.rb +45 -0
- data/examples/catalog/lib/catalog.rb +5 -0
- data/lib/zard/model/v1.rb +111 -0
- data/lib/zard/parsing/parser.rb +1781 -0
- data/lib/zard/version.rb +5 -0
- data/lib/zard.rb +15 -0
- data/sig/zard.rbs +7 -0
- metadata +80 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Use an em dash for named or typed ZARD documentation tags
|
|
2
|
+
|
|
3
|
+
ZARD uses an em dash `—` when a named documentation tag or an optional type must be separated from its description. A tag with neither a name nor a type writes its description directly. InlineRBS keeps `--` as its own contract-note syntax inside `@extrbs`; a YARD-like tag without the required `—` is not a ZARD type hint.
|
|
4
|
+
|
|
5
|
+
## Consequences
|
|
6
|
+
|
|
7
|
+
- `@param value — Input text.` is ZARD documentation.
|
|
8
|
+
- `@param value [String] — Input text.` is ZARD documentation with a claim.
|
|
9
|
+
- `@return Normalized text.` is ZARD documentation without a type claim.
|
|
10
|
+
- `@return — Normalized text.` is accepted, but `zard-doc lint` recommends removing the redundant em dash.
|
|
11
|
+
- `@return [String] — Normalized text.` is ZARD documentation with a claim.
|
|
12
|
+
- `@return [String] Normalized text.` is YARD-like raw text, not a type hint.
|
|
13
|
+
- `@yieldreturn yielded value.` follows the same rule as `@return`.
|
|
14
|
+
- `@option options :format — Output format.` is ZARD documentation.
|
|
15
|
+
- `@option options :format [Symbol] — Output format.` is ZARD documentation with a claim.
|
|
16
|
+
- Tags with no name and no type, such as `@note`, `@see`, `@deprecated`, and `@example`, write their description directly.
|
|
17
|
+
- `@param value [String] Input text.` is preserved as raw text, not as a type hint.
|
|
18
|
+
- Named tags such as `@param`, `@option`, `@yieldparam`, and `@raise` require `—` before their description.
|
|
19
|
+
- `zard-doc lint` warns about YARD-like tags and can promote the warning to an error.
|
|
20
|
+
- `zard-doc lint` may warn when a documentation claim repeats a contract type.
|
|
21
|
+
- ZARD documentation tags require UTF-8 source text. Ruby source encoding declarations remain respected.
|
|
22
|
+
- Every canonical ZARD documentation tag may continue across plain comment lines until another annotation or contract begins; no explicit continuation marker is used.
|
|
23
|
+
- An annotation is recognized only in the first content column immediately after `# `. Indented `@` text remains description content.
|
|
24
|
+
- Internal blank lines, relative indentation, and trailing whitespace are preserved. Leading and trailing blank continuation lines are removed from the normalized description.
|
|
25
|
+
- A multiline description remains one LF-normalized string. Its source span and raw text cover the complete comment block, with raw source bytes and line endings preserved.
|
|
26
|
+
- YARD-like and unknown tags keep their continuation lines as raw text and do not leak them into API documentation.
|
|
27
|
+
- Empty descriptions are preserved with a `documentation.empty-description` warning.
|
|
28
|
+
- Contract annotations end documentation continuation. Contract notes do not use documentation continuation rules.
|
|
29
|
+
- Markdown renderers keep multiline descriptions inside their list item and do not automatically fence `@example` content as code.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Keep the core independent from Rigor and pin the grammar
|
|
2
|
+
|
|
3
|
+
The project uses a monorepo with separate gems for the ZARD core, API documentation, and Rigor integration. The core owns ZARD syntax, tag boundaries, source spans, provenance, and the versioned public model; it keeps `@extrbs` type payloads as text. Rigor owns the payload grammar, grammar revision, inference, and facts; API documentation consumes a versioned structured Rigor lens result when it is available. Subtree splitting is not part of the initial distribution plan.
|
|
4
|
+
|
|
5
|
+
## Consequences
|
|
6
|
+
|
|
7
|
+
- The core can parse and model ZARD without Rigor.
|
|
8
|
+
- The core does not duplicate Rigor's type parser or type semantics.
|
|
9
|
+
- An adapter declares the supported `rigor:v1` grammar revision.
|
|
10
|
+
- `@extrbs` comes first in an annotation block and uses exactly `# @extrbs` with one space.
|
|
11
|
+
- A formatter preserves that order and spacing.
|
|
12
|
+
- Rigor generates `sig/`; the project does not hand-maintain duplicate contracts there.
|
|
13
|
+
- API documentation can be generated without Rigor, but resolved type facts are then unavailable.
|
|
14
|
+
- The Rigor adapter must not expose Rigor internal analyzer classes as the package boundary.
|
|
15
|
+
- The first vertical slice carries class, module, constant, attribute, and method declarations from Ruby source through the ZARD model to Markdown documentation.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Domain Docs
|
|
2
|
+
|
|
3
|
+
Before exploring code, read `CONTEXT.md` at the repo root.
|
|
4
|
+
Also read ADRs in `docs/adr/` that relate to the work.
|
|
5
|
+
|
|
6
|
+
If these files do not exist, continue silently.
|
|
7
|
+
|
|
8
|
+
This repo uses a single-context layout:
|
|
9
|
+
|
|
10
|
+
- `CONTEXT.md`: domain terms and system context
|
|
11
|
+
- `docs/adr/`: architecture decisions
|
|
12
|
+
|
|
13
|
+
Use terms from `CONTEXT.md` in issue titles, plans, and tests.
|
|
14
|
+
If a needed term is missing, note the gap.
|
|
15
|
+
If a change conflicts with an ADR, call out the conflict.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Issue tracker: GitHub
|
|
2
|
+
|
|
3
|
+
Issues and specs for this repo live in GitHub Issues. Use the `gh` CLI.
|
|
4
|
+
|
|
5
|
+
## Writing style
|
|
6
|
+
|
|
7
|
+
Write issue and PR titles, descriptions, and comments in concise English. Lead with the requested behavior or final change. Retain acceptance criteria, dependencies, and relevant validation; link to shared evidence instead of repeating it.
|
|
8
|
+
|
|
9
|
+
## Conventions
|
|
10
|
+
|
|
11
|
+
- Create: `gh issue create --title "..." --body "..."`
|
|
12
|
+
- Read: `gh issue view <number> --comments`
|
|
13
|
+
- List: `gh issue list --state open`
|
|
14
|
+
- Comment: `gh issue comment <number> --body "..."`
|
|
15
|
+
- Add a label: `gh issue edit <number> --add-label "..."`
|
|
16
|
+
- Remove a label: `gh issue edit <number> --remove-label "..."`
|
|
17
|
+
- Close: `gh issue close <number> --comment "..."`
|
|
18
|
+
|
|
19
|
+
PRs are not a triage request surface.
|
|
20
|
+
|
|
21
|
+
When a skill says to publish to the issue tracker, create a GitHub issue.
|
|
22
|
+
When a skill says to fetch a ticket, run `gh issue view <number> --comments`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Triage Labels
|
|
2
|
+
|
|
3
|
+
Use these labels for the five triage roles.
|
|
4
|
+
|
|
5
|
+
| Role | Label | Meaning |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| Needs triage | `needs-triage` | A maintainer must review the issue |
|
|
8
|
+
| Needs information | `needs-info` | The reporter must provide more information |
|
|
9
|
+
| Ready for agent | `ready-for-agent` | The issue is ready for an agent |
|
|
10
|
+
| Ready for human | `ready-for-human` | A human must implement the work |
|
|
11
|
+
| Won't fix | `wontfix` | The issue will not be fixed |
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Supported Ruby Semantics
|
|
2
|
+
|
|
3
|
+
The ZARD parser models modern Ruby declarations statically without executing code. Runtime ancestry, dynamic metaprogramming, and foreign object evaluations are intentionally left unresolved.
|
|
4
|
+
|
|
5
|
+
### Visibility & Modifiers
|
|
6
|
+
|
|
7
|
+
- Declarations record `public`, `protected`, or `private` visibility. Markdown output includes public declarations only.
|
|
8
|
+
- Bare visibility calls, inline forms (`private def`, `private attr_reader`), named method modifiers (`private :read`), and `private_class_method` / `public_class_method` are supported.
|
|
9
|
+
- Visibility calls received by `self` belong to the current scope (method scope for instance visibility, singleton method scope for class methods).
|
|
10
|
+
- `module_function` records its private instance method and public singleton copy as separate declarations with shared provenance. Bare, named, inline, and splatted forms (`module_function(*attr_accessor(:name))`) are supported.
|
|
11
|
+
- `module_function` received by `self` belongs to the current module, like its bare form. Named `module_function` calls may target generated attribute methods, preserving the other accessor side with its original visibility.
|
|
12
|
+
|
|
13
|
+
### Attributes, Aliases & Method Removal
|
|
14
|
+
|
|
15
|
+
- Ruby `attr` declarations default to readers; the legacy `attr :name, true` form is preserved as an accessor. Attributes received by `self` belong to the current owner.
|
|
16
|
+
- Named attribute visibility modifiers are diagnosed because one attribute declaration may generate two methods; use lexical or inline visibility instead.
|
|
17
|
+
- Method aliases preserve their target name and inherit visibility and parameters when declared in the same source scope. Generated attribute readers and writers are valid alias targets (writer aliases use the conventional `value` parameter).
|
|
18
|
+
- Inline visibility and `module_function` modifiers around `alias_method` apply to the resulting alias. `alias_method` received by `self` belongs to the current method scope.
|
|
19
|
+
- Alias documentation remains separate from target documentation.
|
|
20
|
+
- `undef`, `undef_method`, and `remove_method` remove declarations from the current method scope. Removing or replacing one side of an attribute accessor preserves the other side.
|
|
21
|
+
- Later method, alias, and attribute definitions replace earlier declarations of the same name in the same source scope.
|
|
22
|
+
|
|
23
|
+
### Dynamic Definitions & Evaluation Blocks
|
|
24
|
+
|
|
25
|
+
- Literal `define_method` and `define_singleton_method` calls produce method declarations with preserved block parameters, visibility, receiver, refinement scope, and documentation provenance.
|
|
26
|
+
- `define_method` received by `self` belongs to the current method scope.
|
|
27
|
+
- Inline `private define_method`, `module_function define_method`, and class-method visibility modifiers around `define_singleton_method` preserve the visibility produced by Ruby.
|
|
28
|
+
- Declarations in bare or `self` evaluation blocks remain in the current owner. Blocks evaluated by another receiver are not attributed to the lexical owner.
|
|
29
|
+
- In bare or `self.instance_eval` blocks, bare `def` becomes a singleton method, while method-definition calls, attributes, and constants retain their lexical owner. Foreign instance-evaluation blocks are not resolved.
|
|
30
|
+
|
|
31
|
+
### Classes, Modules & Container Builders
|
|
32
|
+
|
|
33
|
+
- Class declarations preserve explicit superclass expressions and source spans without resolving runtime ancestry.
|
|
34
|
+
- Assignments from `Data.define`, `Struct.new`, and `Class.new` produce class declarations; assignments from `Module.new` produce module declarations. Container builders preserve generated attributes and block members within the container scope.
|
|
35
|
+
- Literal Symbol and String member names produce generated attributes; the leading String class name accepted by `Struct.new` is not a member.
|
|
36
|
+
- Named subclasses (e.g. `class Point < Data.define(:x)`) preserve generated attributes while retaining the explicit superclass expression.
|
|
37
|
+
- `Class.new(Struct.new(...))` and `Class.new(Data.define(...))` chains preserve inherited generated attributes when no intermediate factory block can override them.
|
|
38
|
+
- Standard library `DelegateClass(Target)` calls are treated as class builders and preserve the delegated target expression as source provenance.
|
|
39
|
+
- Conditional container builders (`||=`, `Registry = Registry || Module.new`) and transparent `.freeze` tails (including repeated or block forms) are supported.
|
|
40
|
+
|
|
41
|
+
### Mixins, Singletons & Refinements
|
|
42
|
+
|
|
43
|
+
- `include`, `prepend`, and `extend` targets are preserved with source spans and listed in documented containers without resolving inheritance trees. Mixin calls received by `self` belong to the current container.
|
|
44
|
+
- Singleton methods and attributes preserve explicit receiver expressions (or `class <<` expressions).
|
|
45
|
+
- Ruby `refine` blocks and their members remain scoped to the refinement target and separate from ordinary module members. `refine` received by `self` belongs to the current module.
|
|
46
|
+
|
|
47
|
+
### Constants & Namespaces
|
|
48
|
+
|
|
49
|
+
- `private_constant` and `public_constant` update constant visibility in the same namespace. Constant visibility calls received by `self` belong to the current namespace.
|
|
50
|
+
- Bare or `self.autoload` calls with literal Symbol or String names produce constant declarations for the current ordinary owner without guessing the loaded value's kind.
|
|
51
|
+
- Bare or `self.const_set` calls with literal names produce declarations in the current ordinary class or module body; container-builder values retain their generated scope.
|
|
52
|
+
- `remove_const` removes matching declarations and their nested APIs from the current namespace. Unconditional assignments and literal `const_set` replace earlier declarations, while conditional initialization (`||=`) is non-destructive.
|
|
53
|
+
|
|
54
|
+
See the [usage guide](usage.md) for installation, model access, and CLI behavior.
|
|
55
|
+
|
data/docs/usage.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# ZARD 0.0.1 usage
|
|
2
|
+
|
|
3
|
+
ZARD parses Ruby source into a versioned model. The separate `zard-doc` gem renders the model's human-facing API documentation as Markdown. Both `0.0.1` gems are release candidates and are not yet published on RubyGems. Until publication, use the repository as the Gem source:
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
gem "zard", github: "rigortype/zard"
|
|
7
|
+
gem "zard-doc", github: "rigortype/zard"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
After `0.0.1` is published, install the released pair with Bundler:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem "zard", "~> 0.0.1"
|
|
14
|
+
gem "zard-doc", "~> 0.0.1"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The gems require Ruby 3.2 or newer. The project is pre-1.0: the model has an explicit `Zard::Model::V1` namespace, but no general compatibility guarantee has been established yet. Review release notes when upgrading; pre-1.0 releases may change APIs and behavior.
|
|
18
|
+
|
|
19
|
+
## Parse and render
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
require "zard"
|
|
23
|
+
require "zard/doc"
|
|
24
|
+
|
|
25
|
+
source = File.read("lib/example.rb")
|
|
26
|
+
document = Zard.parse(source, path: "lib/example.rb")
|
|
27
|
+
markdown = Zard::Doc.render(document)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`Zard.parse` accepts Ruby source text and a required `path:` used in provenance and diagnostics. The path labels the source; the parser does not read that file. For in-memory input, use a label such as `"example.rb"`. `Zard::Doc.render` accepts the resulting document and returns Markdown. The renderer emits documented public declarations; it does not print contracts as API prose.
|
|
31
|
+
|
|
32
|
+
## Inspect the model
|
|
33
|
+
|
|
34
|
+
The document is available through `document.path`, `document.declarations`, and `document.diagnostics`. A declaration exposes `kind`, `name`, `namespace`, `visibility`, `parameters`, `receiver`, `receiver_span`, `refinement`, `refinement_span`, `alias_target`, `superclass`, `superclass_span`, `container_builder`, `container_builder_span`, `mixins`, `span`, `comment_span`, `documentation`, and `contracts`.
|
|
35
|
+
|
|
36
|
+
Documentation entries are `DocumentationTag` objects with `name`, `owner`, `subject`, `claim`, `description`, `span`, and `raw`. Contract entries are `Contract` objects with `channel`, `payload`, `note`, `span`, and `raw`. Mixins expose `kind`, `target`, and `span`. Diagnostics expose `code`, `severity`, `message`, and `span`.
|
|
37
|
+
|
|
38
|
+
Every source span exposes `path`, `start_line`, `start_column`, `end_line`, `end_column`, `start_offset`, and `end_offset`. Lines are one-based; columns and byte offsets are zero-based, and end positions are exclusive. Raw source and spans make it possible to trace modeled content back to its source. For example:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
document.declarations.each do |declaration|
|
|
42
|
+
declaration.contracts.each do |contract|
|
|
43
|
+
puts "#{contract.channel}: #{contract.payload} at #{contract.span.path}:#{contract.span.start_line}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
document.diagnostics.each do |diagnostic|
|
|
48
|
+
span = diagnostic.span
|
|
49
|
+
warn "#{span.path}:#{span.start_line}: #{diagnostic.severity} #{diagnostic.code}: #{diagnostic.message}"
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Contracts and API documentation
|
|
54
|
+
|
|
55
|
+
Use `@rbs` or `#:` for plain RBS contracts and `@extrbs` for Rigor-specific type information. The parser preserves contract payloads as text; it does not parse or validate their types. Keep contracts distinct from API prose. The `zard-doc` renderer does not copy contract text into Markdown.
|
|
56
|
+
|
|
57
|
+
ZARD uses an em dash (`—`) between a named documentation tag (or an optional type claim) and its description:
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
# @extrbs return: non-empty-string
|
|
61
|
+
# @rbs path: String
|
|
62
|
+
# @rbs return: String
|
|
63
|
+
# @param path — Path to the name file.
|
|
64
|
+
# @return The stored name.
|
|
65
|
+
# @raise IOError — If the file cannot be read.
|
|
66
|
+
def read_name(path)
|
|
67
|
+
File.read(path).strip
|
|
68
|
+
end
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For example, `@param path [String] — The file path.` carries an optional documentation claim. It is not a substitute for `@rbs path: String` and is not checked by this project: there is no Rigor claim checking in this release. The parser may diagnose malformed or noncanonical documentation syntax, but does not validate claims against contracts.
|
|
72
|
+
|
|
73
|
+
Tags without a name or type write their description directly: `@return Normalized value.`, `@note Keep this in mind.`, and `@example Call the method.` Named tags such as `@param`, `@yieldparam`, `@raise`, and `@option` require the marker. `@option options :format — Output format.` documents an option. `@yieldreturn yielded value.` describes a yielded result. Supported tags include `@param`, `@return`, `@yieldparam`, `@yieldreturn`, `@option`, `@raise`, `@note`, `@see`, `@deprecated`, and `@example`.
|
|
74
|
+
|
|
75
|
+
Plain comment lines continue the preceding canonical documentation tag until another annotation or contract begins. No continuation marker is needed. Contract notes use ` -- ` after the contract payload and remain contract notes, not API prose. Familiar YARD-like tags without the em dash can be retained as raw text, but are not treated as documentation claims.
|
|
76
|
+
|
|
77
|
+
ZARD documentation requires UTF-8 source text. Ruby source encoding declarations are respected; non-UTF-8 source can still contain contracts, but documentation text in it receives a diagnostic.
|
|
78
|
+
|
|
79
|
+
## Visibility and analysis boundaries
|
|
80
|
+
|
|
81
|
+
Declarations carry `:public`, `:protected`, or `:private` visibility. `zard-doc` renders only public declarations. The parser statically models supported Ruby declaration forms; it does not execute the program. Runtime-generated declarations, dynamic names, and effects that cannot be determined from supported syntax are not resolved. Superclass, mixin, receiver, and refinement expressions are retained as source references; runtime ancestry and object identity are not inferred.
|
|
82
|
+
|
|
83
|
+
Visibility forms supported by the parser include bare visibility calls, inline forms such as `private def` and `private attr_reader`, named method modifiers such as `private :read`, and `private_class_method` / `public_class_method`. Named attribute modifiers produce a diagnostic because an attribute declaration can generate more than one method. See the [supported Ruby syntax guide](supported-ruby-syntax.md) for detailed coverage.
|
|
84
|
+
|
|
85
|
+
## Command line
|
|
86
|
+
|
|
87
|
+
`zard-doc lint PATH...` checks Ruby files. Directories are searched recursively for `*.rb`; paths are sorted and duplicates removed. Warnings do not fail by default. Use `--fail-on warning` to make warnings fail:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
zard-doc lint lib
|
|
91
|
+
zard-doc lint --fail-on warning lib/example.rb
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`zard-doc render PATH...` renders Markdown to standard output:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
zard-doc render lib
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use `-` as a path to read Ruby source from standard input with either command:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
printf '%s\n' '# @return A value.' 'def value = 1' | zard-doc render -
|
|
104
|
+
printf '%s\n' '# @param value [String] A value.' 'def value = 1' | zard-doc lint -
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Exit codes:
|
|
108
|
+
|
|
109
|
+
- `0`: success; for `lint`, no diagnostic reached the configured failure threshold.
|
|
110
|
+
- `1`: `lint` found a diagnostic at or above its threshold, or `render` found an error diagnostic.
|
|
111
|
+
- `2`: invalid command or options, no Ruby sources found, or an input could not be read.
|
|
112
|
+
|
|
113
|
+
The default lint threshold is `error`. Lint diagnostics are written to standard output. Render diagnostics are written to standard error, and rendering does not emit partial Markdown when an input cannot be read or has an error diagnostic. Calling `Zard::Doc.render` directly does not enforce this CLI error policy; inspect `document.diagnostics` before rendering in an application.
|
|
114
|
+
|
|
115
|
+
## Complete example
|
|
116
|
+
|
|
117
|
+
The repository includes a multi-file catalog example and its expected Markdown:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
bundle exec zard-doc lint examples/catalog/lib
|
|
121
|
+
bundle exec zard-doc render examples/catalog/lib
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
See [the example source](../examples/catalog/lib) and [expected output](../examples/catalog/expected.md). The default verification task exercises this example through the CLI and checks retained contracts and source provenance in the model.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
## Module `Catalog`
|
|
2
|
+
|
|
3
|
+
Catalog keeps a small collection of named entries.
|
|
4
|
+
|
|
5
|
+
## Constant `Catalog::DEFAULT_LIMIT`
|
|
6
|
+
|
|
7
|
+
The default number of entries returned by a search.
|
|
8
|
+
|
|
9
|
+
## Class `Catalog::Entry`
|
|
10
|
+
|
|
11
|
+
A named entry in a catalog.
|
|
12
|
+
This description continues on a plain comment line
|
|
13
|
+
until the next annotation or declaration.
|
|
14
|
+
|
|
15
|
+
## `Catalog::Entry.read_name(path)`
|
|
16
|
+
|
|
17
|
+
### Parameters
|
|
18
|
+
|
|
19
|
+
- `path` — Path to the name file.
|
|
20
|
+
|
|
21
|
+
### Returns
|
|
22
|
+
|
|
23
|
+
The stored name.
|
|
24
|
+
|
|
25
|
+
## `Catalog::Entry#initialize(name)`
|
|
26
|
+
|
|
27
|
+
### Parameters
|
|
28
|
+
|
|
29
|
+
- `name` — Name to store.
|
|
30
|
+
|
|
31
|
+
### Returns
|
|
32
|
+
|
|
33
|
+
The new entry.
|
|
34
|
+
|
|
35
|
+
## Attribute reader `Catalog::Entry#name`
|
|
36
|
+
|
|
37
|
+
The stored entry name.
|
|
38
|
+
|
|
39
|
+
## `Catalog::Entry#label()`
|
|
40
|
+
|
|
41
|
+
### Returns
|
|
42
|
+
|
|
43
|
+
The entry name.
|
|
44
|
+
|
|
45
|
+
## Alias `Catalog::Entry#title`
|
|
46
|
+
|
|
47
|
+
Alias of `Catalog::Entry#label`.
|
|
48
|
+
|
|
49
|
+
### Returns
|
|
50
|
+
|
|
51
|
+
The entry name.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Catalog
|
|
2
|
+
# A named entry in a catalog.
|
|
3
|
+
# This description continues on a plain comment line
|
|
4
|
+
# until the next annotation or declaration.
|
|
5
|
+
class Entry
|
|
6
|
+
# @extrbs return: non-empty-string
|
|
7
|
+
# @rbs path: String
|
|
8
|
+
# @rbs return: String -- The stored value.
|
|
9
|
+
# @param path — Path to the name file.
|
|
10
|
+
# @return The stored name.
|
|
11
|
+
def self.read_name(path)
|
|
12
|
+
File.read(path).strip
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @param name — Name to store.
|
|
16
|
+
# @return The new entry.
|
|
17
|
+
def initialize(name)
|
|
18
|
+
@name = name
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# The stored entry name.
|
|
22
|
+
attr_reader :name
|
|
23
|
+
|
|
24
|
+
# @return The entry name.
|
|
25
|
+
def label
|
|
26
|
+
name
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @return The entry name.
|
|
30
|
+
alias_method :title, :label
|
|
31
|
+
|
|
32
|
+
# @return Internal identifier.
|
|
33
|
+
def internal_id
|
|
34
|
+
name
|
|
35
|
+
end
|
|
36
|
+
private :internal_id
|
|
37
|
+
|
|
38
|
+
protected
|
|
39
|
+
|
|
40
|
+
# @return Whether the entry matches.
|
|
41
|
+
def matches?(candidate)
|
|
42
|
+
name == candidate
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zard
|
|
4
|
+
module Model
|
|
5
|
+
module V1
|
|
6
|
+
class SourceSpan
|
|
7
|
+
attr_reader :path, :start_line, :start_column, :end_line, :end_column, :start_offset, :end_offset
|
|
8
|
+
|
|
9
|
+
def initialize(path:, start_line:, start_column:, end_line:, end_column:, start_offset:, end_offset:)
|
|
10
|
+
@path = path
|
|
11
|
+
@start_line = start_line
|
|
12
|
+
@start_column = start_column
|
|
13
|
+
@end_line = end_line
|
|
14
|
+
@end_column = end_column
|
|
15
|
+
@start_offset = start_offset
|
|
16
|
+
@end_offset = end_offset
|
|
17
|
+
freeze
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Diagnostic
|
|
22
|
+
attr_reader :code, :severity, :message, :span
|
|
23
|
+
|
|
24
|
+
def initialize(code:, severity:, message:, span:)
|
|
25
|
+
@code = code
|
|
26
|
+
@severity = severity
|
|
27
|
+
@message = message
|
|
28
|
+
@span = span
|
|
29
|
+
freeze
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class Contract
|
|
34
|
+
attr_reader :channel, :payload, :note, :span, :raw
|
|
35
|
+
|
|
36
|
+
def initialize(channel:, payload:, note:, span:, raw:)
|
|
37
|
+
@channel = channel
|
|
38
|
+
@payload = payload
|
|
39
|
+
@note = note
|
|
40
|
+
@span = span
|
|
41
|
+
@raw = raw
|
|
42
|
+
freeze
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class DocumentationTag
|
|
47
|
+
attr_reader :name, :owner, :subject, :claim, :description, :span, :raw
|
|
48
|
+
|
|
49
|
+
def initialize(name:, owner:, subject:, claim:, description:, span:, raw:)
|
|
50
|
+
@name = name
|
|
51
|
+
@owner = owner
|
|
52
|
+
@subject = subject
|
|
53
|
+
@claim = claim
|
|
54
|
+
@description = description
|
|
55
|
+
@span = span
|
|
56
|
+
@raw = raw
|
|
57
|
+
freeze
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class MixinReference
|
|
62
|
+
attr_reader :kind, :target, :span
|
|
63
|
+
|
|
64
|
+
def initialize(kind:, target:, span:)
|
|
65
|
+
@kind = kind
|
|
66
|
+
@target = target
|
|
67
|
+
@span = span
|
|
68
|
+
freeze
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class Declaration
|
|
73
|
+
attr_reader :kind, :name, :namespace, :visibility, :parameters, :receiver, :receiver_span, :refinement, :refinement_span, :alias_target, :superclass, :superclass_span, :container_builder, :container_builder_span, :mixins, :span, :comment_span, :documentation, :contracts
|
|
74
|
+
|
|
75
|
+
def initialize(kind:, name:, namespace:, visibility:, parameters:, span:, comment_span:, documentation:, contracts:, receiver: nil, receiver_span: nil, refinement: nil, refinement_span: nil, alias_target: nil, superclass: nil, superclass_span: nil, container_builder: nil, container_builder_span: nil, mixins: [].freeze)
|
|
76
|
+
@kind = kind
|
|
77
|
+
@name = name
|
|
78
|
+
@namespace = namespace
|
|
79
|
+
@visibility = visibility
|
|
80
|
+
@parameters = parameters
|
|
81
|
+
@receiver = receiver
|
|
82
|
+
@receiver_span = receiver_span
|
|
83
|
+
@refinement = refinement
|
|
84
|
+
@refinement_span = refinement_span
|
|
85
|
+
@alias_target = alias_target
|
|
86
|
+
@superclass = superclass
|
|
87
|
+
@superclass_span = superclass_span
|
|
88
|
+
@container_builder = container_builder
|
|
89
|
+
@container_builder_span = container_builder_span
|
|
90
|
+
@mixins = mixins
|
|
91
|
+
@span = span
|
|
92
|
+
@comment_span = comment_span
|
|
93
|
+
@documentation = documentation
|
|
94
|
+
@contracts = contracts
|
|
95
|
+
freeze
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class Document
|
|
100
|
+
attr_reader :path, :declarations, :diagnostics
|
|
101
|
+
|
|
102
|
+
def initialize(path:, declarations:, diagnostics:)
|
|
103
|
+
@path = path
|
|
104
|
+
@declarations = declarations
|
|
105
|
+
@diagnostics = diagnostics
|
|
106
|
+
freeze
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|