Skip to content
This repository was archived by the owner on Nov 19, 2019. It is now read-only.

Commit d7c47c1

Browse files
author
Dylan Pinn
committed
fix(build): Fix build issues caused by updated Google Maps docs
commit by @thzinc from tomchentw#952
1 parent 1bc1420 commit d7c47c1

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/tx/ClassDefinition.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const KlassName = process.argv[2]
1111
fetch(
1212
"https://developers.google.com/maps/documentation/javascript/3.exp/reference"
1313
)
14+
.then(it => it.text())
15+
.then(it => cheerio.load(it))
16+
.then($ => {
17+
const href = $(`#${KlassName} a`).attr("href")
18+
return fetch(href)
19+
})
1420
.then(it => it.text())
1521
.then(it => cheerio.load(it))
1622
.then($ => {
@@ -33,32 +39,25 @@ function contentToJS(KlassName, $, $content) {
3339
const $constructorTable = $content.find(
3440
`[summary="class ${KlassName} - Constructor"]`
3541
)
36-
const [, constructorArgs] = $constructorTable
37-
.find(`tr > td > code`)
42+
const constructorArgs = $constructorTable
43+
.find(`tbody .desc li code:first-child`)
3844
.text()
39-
.match(/\S+\((.*)\)/)
40-
4145
const $methodsTable = $content.find(
4246
`[summary="class ${KlassName} - Methods"]`
4347
)
4448
const methods = $methodsTable
4549
.find("tbody > tr")
4650
.map((i, tr) => {
4751
const $tr = $(tr)
48-
const [, name, args] = $tr
49-
.find("td:first-child")
50-
.text()
51-
.replace("\n", "")
52-
.match(/(\S+)\((.*)\)/)
53-
54-
const returnsDesc = toMarkdown(
55-
$tr.find("td:nth-child(2) > div.desc").html()
56-
)
52+
const name = $tr.find('[itemprop="property"]').text()
53+
const args = $tr.find('.desc:contains("Parameters") li').text()
54+
const returns = $tr.find('.desc:contains("Return Value") code').text()
55+
const returnsDesc = toMarkdown($tr.find(".desc:last-child").html())
5756

5857
return {
5958
name,
6059
args,
61-
returns: $tr.find("td:nth-child(2) > div > code").text(),
60+
returns,
6261
returnsDesc,
6362
}
6463
})

src/tx/MapChild.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default function transformer(file, api) {
122122
return [
123123
...methodAsProps.map(({ name, args, desc }) => {
124124
const [, prop] = name.match(/^set(\S+)/)
125-
const [, maybeType] = args.match(/\S+:(\S+)/)
125+
const [, maybeType] = args.match(/\S+:\s*(\S+)/)
126126

127127
return Object.assign(
128128
j.objectProperty(
@@ -136,7 +136,7 @@ export default function transformer(file, api) {
136136
}),
137137
...methodAsProps.map(({ name, args, desc }) => {
138138
const [, prop] = name.match(/^set(\S+)/)
139-
const [, maybeType] = args.match(/\S+:(\S+)/)
139+
const [, maybeType] = args.match(/\S+:\s*(\S+)/)
140140

141141
return Object.assign(
142142
j.objectProperty(

0 commit comments

Comments
 (0)