Skip to content
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5ea3af4
feat(ast): naive natspec
0xrusowsky Sep 1, 2025
7e24e65
Merge branch 'main' of github.com:paradigmxyz/solar into rusowsky/nat…
0xrusowsky Oct 3, 2025
069235e
feat: support internal tags
0xrusowsky Oct 3, 2025
32313c8
test: natspec ui tests
0xrusowsky Oct 3, 2025
6e4c8fb
perf: drop string allocations
0xrusowsky Oct 3, 2025
5877bd0
fix: global natspec span
0xrusowsky Oct 3, 2025
98c35f7
test: refactor to reduce duplication
0xrusowsky Oct 3, 2025
23e3816
perf: use predefined symbols
0xrusowsky Oct 3, 2025
9bdbadd
chore: refactor to couple `DocComment` and `NatSpecItem`s
0xrusowsky Oct 3, 2025
6c86b25
test: check num of cmnts
0xrusowsky Oct 3, 2025
4c95040
style: clippy
0xrusowsky Oct 3, 2025
c4c89b5
perf: early exist + use memchr
0xrusowsky Oct 4, 2025
4ef62c1
chore: match against string lits + use iterator
0xrusowsky Oct 4, 2025
cbc4272
chore: cleanup
0xrusowsky Oct 4, 2025
5d7a91d
Merge branch 'main' into rusowsky/natspec
0xrusowsky Oct 4, 2025
230ca7a
perf: init smallvec with exact capacity required
0xrusowsky Oct 4, 2025
3f03c7a
perf: drop RawDocComments to avoid extra vec alloc
0xrusowsky Oct 5, 2025
9b2eeef
Merge branch 'main' into rusowsky/natspec
0xrusowsky Oct 5, 2025
379bc56
style: clippy + fmt
0xrusowsky Oct 5, 2025
f331d61
feat(natspec): untagged become `@notice` + content support
0xrusowsky Oct 5, 2025
e495fc8
fix: continue using `Vec` rather than `SmallVec` for `Parser.docs`
0xrusowsky Oct 6, 2025
f01178f
style: clippy
0xrusowsky Oct 6, 2025
9da5417
feat(natspec): ast lowering + inheritdoc resolution
0xrusowsky Oct 6, 2025
e53bb4f
chore: use bitflags
0xrusowsky Oct 7, 2025
2d6164f
refactor natspec validation
0xrusowsky Oct 7, 2025
0b0129f
style
0xrusowsky Oct 8, 2025
bd27387
Merge branch 'main' of github.com:paradigmxyz/solar into rusowsky/low…
0xrusowsky Oct 9, 2025
4de2f48
style
0xrusowsky Oct 10, 2025
19c1b00
fix: add `repr(transparent)` to `DocComments`
0xrusowsky Oct 14, 2025
557ce29
perf: validate all tags + resolve inheritedoc in single pass
0xrusowsky Oct 14, 2025
e29c363
Merge branch 'main' into rusowsky/lower-natspec
0xrusowsky Oct 14, 2025
673fd83
Merge branch 'main' of github.com:paradigmxyz/solar into rusowsky/low…
0xrusowsky Oct 29, 2025
906c10b
fix: allow multiple author tags
0xrusowsky Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/ast/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,18 @@ impl fmt::Debug for DocComments<'_> {
}
}

impl DocComments<'_> {
impl<'ast> DocComments<'ast> {
/// Returns a reference to the empty documentation comments.
pub fn empty() -> &'static Self {
// SAFETY: we're just changing the type wrapper, not the underlying data (which is empty).
unsafe {
std::mem::transmute::<
&'static ThinSlice<DocComment<'static>>,
&'static DocComments<'static>,
>(<&ThinSlice<DocComment<'static>>>::default())
}
}

/// Returns the span containing all doc-comments.
pub fn span(&self) -> Span {
Span::join_first_last(self.iter().map(|d| d.span))
Expand Down
4 changes: 2 additions & 2 deletions crates/ast/src/ast/natspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ pub enum NatSpecKind {
Param { name: Ident },
/// `@return <name>`
///
/// Documents a return variable. The `name` field contains the return variable name.
Return { name: Ident },
/// Documents a return variable. The optional `name` field contains the return variable name.
Return { name: Option<Ident> },
/// `@inheritdoc <contract>`
///
/// Copies all tags from the base function. The `contract` field contains the contract name.
Expand Down
8 changes: 6 additions & 2 deletions crates/parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,9 @@ fn parse_natspec(
let ident = Ident::new(Symbol::intern(name), comment_span);
match tag {
"param" => ast::NatSpecKind::Param { name: ident },
"return" => ast::NatSpecKind::Return { name: ident },
"return" => ast::NatSpecKind::Return {
name: if content_start_pos == line_end { None } else { Some(ident) },
},
"inheritdoc" => ast::NatSpecKind::Inheritdoc { contract: ident },
_ => unreachable!(),
}
Expand Down Expand Up @@ -1187,7 +1189,9 @@ mod tests {
ast::NatSpecKind::Notice if kind == "notice" => None,
ast::NatSpecKind::Dev if kind == "dev" => None,
ast::NatSpecKind::Param { name } if kind == "param" => Some(name.name.as_str()),
ast::NatSpecKind::Return { name } if kind == "return" => Some(name.name.as_str()),
ast::NatSpecKind::Return { name } if kind == "return" => {
name.as_ref().map(|n| n.name.as_str())
}
ast::NatSpecKind::Inheritdoc { contract } if kind == "inheritdoc" => {
Some(contract.name.as_str())
}
Expand Down
Loading
Loading