Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
P
prettier-plugin-jsdoc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gumen
prettier-plugin-jsdoc
Commits
adf7dd02
Commit
adf7dd02
authored
Jan 23, 2020
by
Wiktor Walasek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add options for dot (fixes tests) and decription tag
parent
5df3d66d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
8 deletions
+27
-8
jsdoc_parser.js
jsdoc_parser.js
+27
-8
No files found.
jsdoc_parser.js
View file @
adf7dd02
...
...
@@ -43,12 +43,13 @@ const tagSynonyms = {
* @param {String} text
* @return {String}
*/
function
formatDescription
(
text
)
{
text
=
text
?
text
.
trim
()
:
''
function
formatDescription
(
text
,
insertDot
)
{
if
(
!
text
)
return
''
text
=
text
.
replace
(
/
\s\s
+/g
,
'
'
)
// Avoid multiple spaces
text
=
text
.
replace
(
/
\n
/g
,
'
'
)
// Make single line
text
=
text
[
0
].
toUpperCase
()
+
text
.
slice
(
1
)
// Capitalize
text
=
text
.
trim
()
text
=
text
.
replace
(
/
\s\s
+/g
,
'
'
)
// Avoid multiple spaces
text
=
text
.
replace
(
/
\n
/g
,
'
'
)
// Make single line
if
(
insertDot
)
text
=
text
.
replace
(
/
(\w)(?=
$
)
/g
,
'
$1.
'
)
// Insert dot if needed
text
=
text
[
0
].
toUpperCase
()
+
text
.
slice
(
1
)
// Capitalize
return
text
||
''
}
...
...
@@ -124,10 +125,10 @@ function jsdocParser(text, parsers, options) {
}
if
([
'
description
'
,
'
param
'
,
'
return
'
,
'
todo
'
].
includes
(
tag
.
title
))
tag
.
description
=
formatDescription
(
tag
.
description
)
tag
.
description
=
formatDescription
(
tag
.
description
,
options
.
jsdocAddDotToDescription
)
if
(
!
tag
.
description
&&
[
'
description
'
,
'
param
'
,
'
return
'
,
'
todo
'
,
'
memberof
'
].
includes
(
tag
.
title
))
tag
.
description
=
'
TODO
'
tag
.
description
=
formatDescription
(
'
TODO
'
,
options
.
jsdocAddDotToDescription
)
return
tag
})
...
...
@@ -137,7 +138,12 @@ function jsdocParser(text, parsers, options) {
// Create final jsDoc string
.
forEach
((
tag
,
tagIndex
)
=>
{
let
tagString
=
` * @
${
tag
.
title
}
`
let
tagString
if
(
tag
.
title
!==
'
description
'
||
options
.
jsdocDescriptionTag
)
tagString
=
` * @
${
tag
.
title
}
`
else
tagString
=
` * `
if
(
tag
.
type
&&
tag
.
type
.
name
)
tagString
+=
gap
+
`{
${
tag
.
type
.
name
}
}`
if
(
tag
.
name
)
tagString
+=
gap
+
tag
.
name
...
...
@@ -237,10 +243,23 @@ module.exports = {
'
return
'
,
]}],
description
:
'
Define order of tags.
'
,
},
jsdocAddDotToDescription
:
{
type
:
'
boolean
'
,
category
:
'
Global
'
,
default
:
true
,
description
:
'
Punctuation, is: a. key?
'
},
jsdocDescriptionTag
:
{
type
:
'
boolean
'
,
category
:
'
Global
'
,
default
:
true
,
description
:
'
please disable me
'
,
}
},
defaultOptions
:
{
jsdocSpaces
:
1
,
jsdocPrintWidth
:
80
,
jsdocDescriptionTag
:
true
,
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment