Skip to content

fix: Applying extra markdown content before first header #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2021
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
17 changes: 13 additions & 4 deletions docgen/post-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async function readExtraContentFrom(source) {
const reader = readline.createInterface({
input: fs.createReadStream(source),
});
const content = [''];
const content = [];
for await (const line of reader) {
content.push(line);
}
Expand All @@ -150,11 +150,20 @@ async function writeExtraContentTo(target, extra) {
const reader = readline.createInterface({
input: fs.createReadStream(target),
});

let firstHeadingSeen = false;
for await (const line of reader) {
output.push(line);
if (line.startsWith('{% block body %}')) {
output.push(...extra);
// Insert extra content just before the first markdown heading.
if (line.match(/^\#+ /)) {
if (!firstHeadingSeen) {
output.push(...extra);
output.push('');
}

firstHeadingSeen = true;
}

output.push(line);
}

const outputBuffer = Buffer.from(output.join('\r\n'));
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"test:coverage": "nyc npm run test:unit",
"lint:src": "eslint src/ --ext .ts",
"lint:test": "eslint test/ --ext .ts",
"apidocs": "run-s api-extractor:local api-documenter api-documenter:toc api-documenter:post",
"apidocs": "run-s api-extractor:local api-documenter",
"api-extractor": "node generate-reports.js",
"api-extractor:local": "npm run build && node generate-reports.js --local",
"esm-wrap": "node generate-esm-wrapper.js",
"api-documenter": "api-documenter-fire markdown --input temp --output docgen/markdown -s",
"api-documenter": "run-s api-documenter:markdown api-documenter:toc api-documenter:post",
"api-documenter:markdown": "api-documenter-fire markdown --input temp --output docgen/markdown -s",
"api-documenter:toc": "api-documenter-fire toc --input temp --output docgen/markdown -p /docs/reference/admin/node -s",
"api-documenter:post": "node docgen/post-process.js"
},
Expand Down
10 changes: 5 additions & 5 deletions src/app-check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { app } from '../firebase-namespace-api';
* @param app Optional app for which to return the `AppCheck` service.
* If not provided, the default `AppCheck` service is returned.
*
* @return The default `AppCheck` service if no
* @returns The default `AppCheck` service if no
* app is provided, or the `AppCheck` service associated with the provided
* app.
*/
Expand All @@ -59,10 +59,10 @@ export namespace appCheck {
/**
* Creates a new {@link appCheck.AppCheckToken `AppCheckToken`} that can be sent
* back to a client.
*
*
* @param appId The App ID of the Firebase App the token belongs to.
*
* @return A promise that fulfills with a `AppCheckToken`.
* @returns A promise that fulfills with a `AppCheckToken`.
*/
createToken(appId: string): Promise<AppCheckToken>;

Expand All @@ -73,7 +73,7 @@ export namespace appCheck {
*
* @param appCheckToken The App Check token to verify.
*
* @return A promise fulfilled with the
* @returns A promise fulfilled with the
* token's decoded claims if the App Check token is valid; otherwise, a rejected
* promise.
*/
Expand Down Expand Up @@ -146,7 +146,7 @@ export namespace appCheck {
app_id: string;
[key: string]: any;
}

/**
* Interface representing a verified App Check token response.
*/
Expand Down