Skip to content

Commit 9385fd5

Browse files
committed
docs(semantic): add docs for JSDocCommentPart
1 parent 0fce6ce commit 9385fd5

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

crates/oxc_semantic/src/jsdoc/parser/jsdoc_parts.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
use oxc_span::Span;
22

3-
/// Used for `JSDoc.comment` and `JSDocTag.comment`
3+
/// Represents the raw text of a JSDoc tag *outside* the type expression (`{}`) and tag name (e.g., `@param`),
4+
/// such as the parameter name or trailing description.
5+
///
6+
/// This is used to capture parts of a JSDoc tag that aren't types but still carry semantic meaning,
7+
/// for example, the name `bar` or the description text in `@param {foo=} bar Some description`.
8+
///
9+
/// ```js
10+
/// /**
11+
/// * @param {foo=} bar Some description
12+
/// * ^^^^^^^^^^^^^^^^^^^^
13+
/// * This is the `JSDocCommentPart`
14+
/// */
15+
/// ```
16+
///
17+
/// It does **not** include the type (inside `{}`) or the tag name (`@param`).
18+
/// Used to populate the `.comment` field on `JSDoc` and `JSDocTag` nodes.
419
#[derive(Debug, Clone, Copy)]
520
pub struct JSDocCommentPart<'a> {
21+
/// The raw string content, such as a parameter name or freeform description text.
622
raw: &'a str,
23+
24+
/// The span in the source text corresponding to this part.
725
pub span: Span,
826
}
27+
928
impl<'a> JSDocCommentPart<'a> {
1029
pub fn new(part_content: &'a str, span: Span) -> Self {
1130
Self { raw: part_content, span }

0 commit comments

Comments
 (0)