Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions docgen/content-sources/v2/HOME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Firebase Functions v2 SDK Reference

The `firebase-functions` package provides an SDK for defining Cloud Functions for Firebase.

To get started using Cloud Functions, see
[Get started: write, test, and deploy your first functions](/docs/functions/get-started).

For source code, see the [Cloud Functions for Firebase GitHub repo](https://github.com/firebase/firebase-functions).
27 changes: 27 additions & 0 deletions docgen/content-sources/v2/toc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
toc:
- title: globals.html
path: /docs/reference/functions/globals.html
- title: index.html
path: /docs/reference/functions/index.html
- title: logger_common_.html
path: /docs/reference/functions/logger_common_.html
- title: logger_compat_.html
path: /docs/reference/functions/logger_compat_.html
- title: logger_index_.html
path: /docs/reference/functions/logger_index_.html
- title: logger_index_.logentry.html
path: /docs/reference/functions/logger_index_.logentry.html
- title: v2_base_.html
path: /docs/reference/functions/v2_base_.html
- title: v2_index_.html
path: /docs/reference/functions/v2_index_.html
- title: v2_options_.eventhandleroptions.html
path: /docs/reference/functions/v2_options_.eventhandleroptions.html
- title: v2_options_.globaloptions.html
path: /docs/reference/functions/v2_options_.globaloptions.html
- title: v2_options_.html
path: /docs/reference/functions/v2_options_.html
- title: v2_providers_https_.html
path: /docs/reference/functions/v2_providers_https_.html
- title: v2_providers_https_.httpsoptions.html
path: /docs/reference/functions/v2_providers_https_.httpsoptions.html
29 changes: 23 additions & 6 deletions docgen/generate-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,38 @@ const yaml = require('js-yaml');
const repoPath = path.resolve(`${__dirname}/..`);

// Command-line options.
const { source: sourceFile } = yargs
.option('source', {
default: `${repoPath}/src/{v1,logger}`,
const { api: apiVersion } = yargs
.option('api', {
default: 'v1',
describe: 'Typescript source file(s)',
type: 'string',
})
.version(false)
.help().argv;

let sourceFile;
switch (apiVersion) {
case 'v1':
sourceFile = `${repoPath}/src/{v1,logger}`;
break;
case 'v2':
sourceFile = `${repoPath}/src/{v2,logger}`;
break;
default:
throw new Error(
`Unrecognized version ${apiVersion}, must be one of v1 or v2`
);
}

const docPath = path.resolve(`${__dirname}/html`);
const contentPath = path.resolve(`${__dirname}/content-sources`);
const contentPath = path.resolve(`${__dirname}/content-sources/${apiVersion}`);
const tempHomePath = path.resolve(`${contentPath}/HOME_TEMP.md`);
const devsitePath = `/docs/reference/functions/`;

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

const typeMap = require('./type-aliases.json');
const { existsSync } = require('fs');

/**
* Strips path prefix and returns only filename.
Expand Down Expand Up @@ -72,8 +87,10 @@ function runTypedoc() {
* @param {string} subdir Subdir to move files out of.
*/
async function moveFilesToRoot(subdir) {
await exec(`mv ${docPath}/${subdir}/* ${docPath}`);
await exec(`rmdir ${docPath}/${subdir}`);
if (existsSync(`${docPath}/${subdir}`)) {
await exec(`mv ${docPath}/${subdir}/* ${docPath}`);
await exec(`rmdir ${docPath}/${subdir}`);
}
}

/**
Expand Down