Skip to content

Commit de94b78

Browse files
authored
[apidocs] Improve file detection and updates toc.yaml (#936)
1 parent b3c232f commit de94b78

File tree

2 files changed

+44
-25
lines changed

2 files changed

+44
-25
lines changed

docgen/content-sources/v2/toc.yaml

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
toc:
2-
- title: globals.html
3-
path: /docs/reference/functions/modules.html
4-
- title: index.html
5-
path: /docs/reference/functions/index.html
6-
- title: logger_common.html
7-
path: /docs/reference/functions/logger_common.html
8-
- title: logger.LogEntry.html
9-
path: /docs/reference/functions/logger.LogEntry.html
10-
- title: v2_core.html
11-
path: /docs/reference/functions/v2_core.html
12-
- title: v2.html
13-
path: /docs/reference/functions/v2.html
14-
- title: v2_options.eventhandleroptions.html
15-
path: /docs/reference/functions/v2_options.eventhandleroptions.html
16-
- title: v2_options.globaloptions.html
17-
path: /docs/reference/functions/v2_options.globaloptions.html
18-
- title: v2_options.html
19-
path: /docs/reference/functions/v2_options.html
20-
- title: v2_providers_https.html
21-
path: /docs/reference/functions/v2_providers_https.html
22-
- title: v2_providers_https.httpsoptions.html
23-
path: /docs/reference/functions/v2_providers_https.httpsoptions.html
2+
- title: functions
3+
path: /docs/functions/alpha/v2.html
4+
- title: functions.core
5+
path: /docs/functions/alpha/v2_core.html
6+
section:
7+
- title: functions.CloudEvent
8+
path: /docs/functions/alpha/v2_core.cloudevent.html
9+
- title: functions.CloudFunction
10+
path: /docs/functions/alpha/v2_core.cloudfunction.html
11+
- title: functions.https
12+
path: /docs/functions/alpha/v2_providers_https.html
13+
section:
14+
- title: functions.https.options
15+
path: /docs/functions/alpha/v2_providers_https.httpsoptions.html
16+
- title: 'functions.logger'
17+
path: /docs/functions/alpha/logger.html
18+
section:
19+
- title: 'LogEntry'
20+
path: /docs/functions/alpha/logger.LogEntry.html
21+
- title: functions.options
22+
path: /docs/functions/alpha/v2_options.html
23+
section:
24+
- title: functions.options.GlobalOptions
25+
path: /docs/functions/alpha/v2_options.globaloptions.html
26+
- title: functions.options.EventHandlerOptions
27+
path: /docs/functions/alpha/v2_options.eventhandleroptions.html
28+
- title: functions.params
29+
path: /docs/functions/alpha/v2_params.html
30+
- title: 'functions.pubsub'
31+
path: /docs/functions/v2_providers_pubsub.html
32+
section:
33+
- title: 'Message'
34+
path: /docs/functions/alpha/v2_providers_pubsub.Message.html
35+
- title: 'TopicBuilder'
36+
path: /docs/functions/alpha/v2_providers_pubsub.MessagePublishedData.html
37+
- title: 'PubSubOptions'
38+
path: /docs/functions/alpha/v2_providers_pubsub.PubSubOptions.html

docgen/generate-docs.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ const { api: apiVersion } = yargs
3333
.version(false)
3434
.help().argv;
3535

36-
let sourceFile;
36+
let sourceFile, devsitePath;
3737
switch (apiVersion) {
3838
case 'v1':
3939
sourceFile = `${repoPath}/src/{v1,logger}`;
40+
devsitePath = '/docs/reference/functions/';
4041
break;
4142
case 'v2':
4243
sourceFile = `${repoPath}/src/{v2,logger}`;
44+
devsitePath = '/docs/functions/alpha/';
4345
break;
4446
default:
4547
throw new Error(
@@ -50,7 +52,6 @@ switch (apiVersion) {
5052
const docPath = path.resolve(`${__dirname}/html`);
5153
const contentPath = path.resolve(`${__dirname}/content-sources/${apiVersion}`);
5254
const tempHomePath = path.resolve(`${contentPath}/HOME_TEMP.md`);
53-
const devsitePath = `/docs/reference/functions/`;
5455

5556
const { JSDOM } = require('jsdom');
5657

@@ -198,7 +199,10 @@ async function checkForMissingFilesAndFixFilenameCase(tocText) {
198199
const filenames = tocText
199200
.split('\n')
200201
.filter((line) => line.includes('path:'))
201-
.map((line) => line.split(devsitePath)[1].replace(/#.*$/, ''));
202+
.map((line) => {
203+
parts = line.split('/');
204+
return parts[parts.length - 1].replace(/#.*$/, '');
205+
});
202206
// Logs warning to console if a file from TOC is not found.
203207
const fileCheckPromises = filenames.map(async (filename) => {
204208
// Warns if file does not exist, fixes filename case if it does.

0 commit comments

Comments
 (0)