Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow using raw docstring for type docs #28

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

logikone
Copy link
Contributor

@logikone logikone commented Jul 1, 2022

closes #27

config/config.go Outdated
@@ -33,6 +33,7 @@ type ProcessorConfig struct {
IgnoreTypes []string `json:"ignoreTypes"`
IgnoreFields []string `json:"ignoreFields"`
IgnoreGroupVersions []string `json:"ignoreGroupVersions"`
TypeDocstringRaw bool `json:"typeDocstringRaw"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming: maybe this is more explicit?

Suggested change
TypeDocstringRaw bool `json:"typeDocstringRaw"`
UseRawDocstring bool `json:"useRawDocstring"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated 👍

@@ -265,6 +265,10 @@ func (p *processor) processType(pkg *loader.Package, info *markers.TypeInfo, dep
Doc: info.Doc,
}

if p.typeDocstringRaw && info.RawDecl != nil {
typeDef.Doc = info.RawDecl.Doc.Text()
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment?
Also, I see a new line added at the end, should we remove it?

Suggested change
typeDef.Doc = info.RawDecl.Doc.Text()
// use raw comments doc to support multi-line and indent preservation
typeDef.Doc = strings.TrimSuffix(info.RawDecl.Doc.Text(), "\n") // remove trailing newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

commend add and newline trimmed 👍

@logikone logikone force-pushed the type-docstring-raw branch 2 times, most recently from 7b7e9c0 to c81a784 Compare July 5, 2022 18:29
Copy link
Contributor

@thbkrkr thbkrkr left a comment

Choose a reason for hiding this comment

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

LGTM

@thbkrkr thbkrkr merged commit 49339ae into elastic:master Jul 5, 2022
@mowies
Copy link

mowies commented Feb 22, 2023

@thbkrkr it would be great to have this released :)

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.

TypeInfo.RawDecl.Doc instead of TypeInfo.Doc for Type documentation
3 participants