Skip to content

Comments configuration#32

Open
Vladyslav-Kuksiuk wants to merge 28 commits into
masterfrom
comments-configuration
Open

Comments configuration#32
Vladyslav-Kuksiuk wants to merge 28 commits into
masterfrom
comments-configuration

Conversation

@Vladyslav-Kuksiuk
Copy link
Copy Markdown
Collaborator

@Vladyslav-Kuksiuk Vladyslav-Kuksiuk commented May 18, 2026

This PR provides comments filtration option.

How to use

Add the comments parameter to the embed-code tag.

<embed-code
  file="myFile.java"
  comments="none" />
```java
```

Supported values

  • all — retain all comments. This is the default.
  • none — strip all recognized comments.
  • documentation — retain documentation comments such as Javadoc, KDoc etc.
  • regular — retain regular comments, including block and inline comments, but strip documentation comments.
  • inline — retain regular inline comments such as //.
  • block — retain regular block comments such as /* */.

Not every mode has a distinct meaning for every supported file type.
For example, XML, HTML, and YAML support only all and none.

Supported formats

Comment filtering is supported for:

  • Java, Kotlin, KTS, Groovy
  • C, C++, C#
  • JavaScript, TypeScript
  • YAML
  • XML, HTML
  • Visual Basic
  • Python
  • Go
  • Protobuf

Unsupported file types are left unchanged, and a warning is emitted when comment filtering other than all is requested.

Resolves this issue.

Additional changes

  • Improved multiple errors output:
image
  • Updated check mode "outdated" output and throw error on it:
image

@Vladyslav-Kuksiuk Vladyslav-Kuksiuk self-assigned this May 18, 2026
@alexander-yevsyukov
Copy link
Copy Markdown
Contributor

documentation — retain documentation comments such as Javadoc, KDoc.

This parameter should be treated in context of the embedded file and depend on the type of the programming language of the embedded file. Javadoc, and KDoc are only two formats that use the same convention for the comments (/** */).

For other programming languages that we use (Go, Python, JavaScript, TypeScript, etc.) we should treat comments according to the language contentions.

For some file formats, the documentation parameter should not be applicable and should cause an error. For example, there's nothing documentation in a Markdown or .properties file.

Please have a look around of the file types we use in our projects and use them for sensible defaults.

@Vladyslav-Kuksiuk Vladyslav-Kuksiuk marked this pull request as ready for review May 20, 2026 11:02
Copy link
Copy Markdown
Collaborator

@dmytro-kashcheiev dmytro-kashcheiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vladyslav-Kuksiuk LGTM with minor comments.

)

// VisualBasicCommentFilter filters the Visual Basic comment forms:
// - documentation comments starting with `”'`;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure? to many quotes maybe typo?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a documentation style of the Visual Basic('''), but IDEA by some reasons converts two single quotes('') into .

Comment on lines +83 to +85
warnUnsupportedCommentsMode(filePath, mode, embeddingDocPath, embeddingLine, entry.supportedModes)

return entry.filter, true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this. Still, the comment rules are applied to an explicit fragment, which means that we know the type of the source code.
In that case, probably it's not correct to simply warn about the misconfiguration and after return some filter. Isn't it should be same as above that in that case we return nil, false ?

@alexander-yevsyukov
Copy link
Copy Markdown
Contributor

@dmytro-kashcheiev, @Oleg-Melnik, why does this PR hang unmerged that long? Do you expect me to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support comments parameter

3 participants