Skip to content

Commit 05c3828

Browse files
authored
convert golang Deprecated: into JSDoc @deprecated (#64)
* convert golang Deprecated: into JSDoc @deprecated
1 parent 66099c2 commit 05c3828

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

bindings/bindings.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ func (b *Bindings) CommentGojaObject(comments []SyntheticComment, object *goja.O
756756
sep := ""
757757
for _, cmt := range jsDoc {
758758
jsDocComment.WriteString(sep)
759-
jsDocComment.WriteString(cmt.Text)
759+
jsDocComment.WriteString(convertDeprecation(cmt.Text))
760760
sep = "\n *"
761761
}
762762
jsDocComment.WriteString("\n ")
@@ -790,3 +790,11 @@ func (b *Bindings) CommentGojaObject(comments []SyntheticComment, object *goja.O
790790

791791
return node, nil
792792
}
793+
794+
func convertDeprecation(txt string) string {
795+
if len(txt) > 13 && txt[:13] == " Deprecated: " {
796+
return " @deprecated " + txt[13:]
797+
}
798+
799+
return txt
800+
}

testdata/comments/comments.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ type BlockComment struct {
4141

4242
// Constant is just a value
4343
const Constant = "value" // An inline note
44+
45+
// DeprecatedComment is a comment with a deprecation note
46+
//
47+
// Deprecated: this type is no longer used
48+
type DeprecatedComment struct {
49+
}

testdata/comments/comments.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ export interface CommentedStructure {
4343
export const Constant = "value"; // An inline note
4444

4545

46+
// From comments/comments.go
47+
/**
48+
* DeprecatedComment is a comment with a deprecation note
49+
*
50+
* @deprecated this type is no longer used
51+
*/
52+
export interface DeprecatedComment {
53+
}
54+
4655
// From comments/comments.go
4756
export interface InheritedCommentedStructure extends CommentedStructure {
4857
}

0 commit comments

Comments
 (0)