Skip to content

Commit 8557993

Browse files
authored
Add a few missing docstrings for API docs (JuliaLang/JuliaSyntax.jl#301)
1 parent 908923a commit 8557993

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

JuliaSyntax/docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ makedocs(;
1414
],
1515
repo="https://github.com/JuliaLang/JuliaSyntax.jl/blob/{commit}{path}#L{line}",
1616
sitename="JuliaSyntax.jl",
17-
authors = "Claire Foster and contributors: https://github.com/JuliaLang/JuliaSyntax.jl/graphs/contributors"
17+
authors = "Claire Foster and contributors: https://github.com/JuliaLang/JuliaSyntax.jl/graphs/contributors",
18+
strict = Documenter.except(:missing_docs)
1819
)
1920

2021
deploydocs(;

JuliaSyntax/docs/src/api.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ JuliaSyntax.parseatom
1313
The `ParseStream` interface which provides a low-level stream-like I/O
1414
interface for writing the parser. The parser does not depend on or produce any
1515
concrete tree data structure as part of the parsing phase but the output spans
16-
can be post-processed into various tree data structures as required.
16+
can be post-processed into various tree data structures as required using
17+
[`JuliaSyntax.build_tree`](@ref).
1718

1819
```@docs
1920
JuliaSyntax.parse!
2021
JuliaSyntax.ParseStream
22+
JuliaSyntax.build_tree
2123
```
2224

2325
## Tokenization
@@ -41,6 +43,8 @@ JuliaSyntax.source_location
4143
## Expression heads/kinds
4244

4345
```@docs
46+
JuliaSyntax.Kind
47+
JuliaSyntax.SyntaxHead
4448
JuliaSyntax.@K_str
4549
JuliaSyntax.kind
4650
JuliaSyntax.head

JuliaSyntax/src/parse_stream.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,30 @@ end
6969
has_flags(flags::RawFlags, test_flags) = (flags & test_flags) != 0
7070

7171
#-------------------------------------------------------------------------------
72+
"""
73+
SyntaxHead(kind, flags)
74+
75+
A `SyntaxHead` combines the [`Kind`](@ref) of a syntactic construct with a set
76+
of flags. The kind defines the broad "type" of the syntactic construct, while
77+
the flag bits compactly store more detailed information about the construct.
78+
"""
7279
struct SyntaxHead
7380
kind::Kind
7481
flags::RawFlags
7582
end
7683

7784
kind(head::SyntaxHead) = head.kind
85+
86+
"""
87+
flags(x)
88+
89+
Return the flag bits of a syntactic construct. Prefer to query these with the
90+
predicates `is_trivia`, `is_prefix_call`, `is_infix_op_call`,
91+
`is_prefix_op_call`, `is_postfix_op_call`, `is_dotted`, `is_suffixed`,
92+
`is_decorated`.
93+
94+
Or extract numeric portion of the flags with `numeric_flags`.
95+
"""
7896
flags(head::SyntaxHead) = head.flags
7997

8098
function Base.summary(head::SyntaxHead)

JuliaSyntax/src/source_files.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ function _source_line_index(source::SourceFile, byte_index)
4040
return (lineidx < lastindex(source.line_starts)) ? lineidx : lineidx-1
4141
end
4242
_source_line(source::SourceFile, lineidx) = lineidx + source.first_line - 1
43+
44+
"""
45+
Get the line number at the given byte index.
46+
"""
4347
source_line(source::SourceFile, byte_index) = _source_line(source, _source_line_index(source, byte_index))
4448

4549
"""

JuliaSyntax/src/syntax_tree.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ haschildren(node::TreeNode) = node.children !== nothing
9696
children(node::TreeNode) = (c = node.children; return c === nothing ? () : c)
9797

9898

99+
"""
100+
head(x)
101+
102+
Get the [`SyntaxHead`](@ref) of a node of a tree or other syntax-related data
103+
structure.
104+
"""
99105
head(node::AbstractSyntaxNode) = head(node.raw)
100106

101107
span(node::AbstractSyntaxNode) = span(node.raw)

0 commit comments

Comments
 (0)