FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
atom/script/lib/generate-api-docs.js at master · SamB/atom · GitHub
SamB
/
atom
Public
forked from
atom/atom
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
atom
/
script
/
lib
/
generate-api-docs.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (46 loc) · 1.67 KB
Breadcrumbs
atom
/
script
/
lib
/
generate-api-docs.js
Copy path
File metadata and controls
55 lines (46 loc) · 1.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict'
;
const
donna
=
require
(
'donna'
)
;
const
tello
=
require
(
'tello'
)
;
const
joanna
=
require
(
'joanna'
)
;
const
glob
=
require
(
'glob'
)
;
const
fs
=
require
(
'fs-extra'
)
;
const
path
=
require
(
'path'
)
;
const
CONFIG
=
require
(
'../config'
)
;
module
.
exports
=
function
(
)
{
const
generatedJSONPath
=
path
.
join
(
CONFIG
.
docsOutputPath
,
'atom-api.json'
)
;
console
.
log
(
`Generating API docs at
${
generatedJSONPath
}
`
)
;
// Unfortunately, correct relative paths depend on a specific working
// directory, but this script should be able to run from anywhere, so we
// muck with the cwd temporarily.
const
oldWorkingDirectoryPath
=
process
.
cwd
(
)
;
process
.
chdir
(
CONFIG
.
repositoryRootPath
)
;
const
coffeeMetadata
=
donna
.
generateMetadata
(
[
'.'
]
)
[
0
]
;
const
jsMetadata
=
joanna
(
glob
.
sync
(
`src/**/*.js`
)
)
;
process
.
chdir
(
oldWorkingDirectoryPath
)
;
const
metadata
=
{
repository
:
coffeeMetadata
.
repository
,
version
:
coffeeMetadata
.
version
,
files
:
Object
.
assign
(
coffeeMetadata
.
files
,
jsMetadata
.
files
)
}
;
const
api
=
tello
.
digest
(
[
metadata
]
)
;
Object
.
assign
(
api
.
classes
,
getAPIDocsForDependencies
(
)
)
;
api
.
classes
=
sortObjectByKey
(
api
.
classes
)
;
fs
.
mkdirpSync
(
CONFIG
.
docsOutputPath
)
;
fs
.
writeFileSync
(
generatedJSONPath
,
JSON
.
stringify
(
api
,
null
,
2
)
)
;
}
;
function
getAPIDocsForDependencies
(
)
{
const
classes
=
{
}
;
for
(
let
apiJSONPath
of
glob
.
sync
(
`
${
CONFIG
.
repositoryRootPath
}
/node_modules/*/api.json`
)
)
{
Object
.
assign
(
classes
,
require
(
apiJSONPath
)
.
classes
)
;
}
return
classes
;
}
function
sortObjectByKey
(
object
)
{
const
sortedObject
=
{
}
;
for
(
let
keyName
of
Object
.
keys
(
object
)
.
sort
(
)
)
{
sortedObject
[
keyName
]
=
object
[
keyName
]
;
}
return
sortedObject
;
}
Back
|
FazBrowse Home
|
New Git URL