Skip to content

Commit 244a9af

Browse files
authored
fix: Applying extra markdown content before first header (#1317)
* fix: Applying extra markdown content before first header * fix: Better reg-ex for detecting markdown heading
1 parent f65deae commit 244a9af

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

docgen/post-process.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async function readExtraContentFrom(source) {
137137
const reader = readline.createInterface({
138138
input: fs.createReadStream(source),
139139
});
140-
const content = [''];
140+
const content = [];
141141
for await (const line of reader) {
142142
content.push(line);
143143
}
@@ -150,11 +150,20 @@ async function writeExtraContentTo(target, extra) {
150150
const reader = readline.createInterface({
151151
input: fs.createReadStream(target),
152152
});
153+
154+
let firstHeadingSeen = false;
153155
for await (const line of reader) {
154-
output.push(line);
155-
if (line.startsWith('{% block body %}')) {
156-
output.push(...extra);
156+
// Insert extra content just before the first markdown heading.
157+
if (line.match(/^\#+ /)) {
158+
if (!firstHeadingSeen) {
159+
output.push(...extra);
160+
output.push('');
161+
}
162+
163+
firstHeadingSeen = true;
157164
}
165+
166+
output.push(line);
158167
}
159168

160169
const outputBuffer = Buffer.from(output.join('\r\n'));

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
"test:coverage": "nyc npm run test:unit",
2121
"lint:src": "eslint src/ --ext .ts",
2222
"lint:test": "eslint test/ --ext .ts",
23-
"apidocs": "run-s api-extractor:local api-documenter api-documenter:toc api-documenter:post",
23+
"apidocs": "run-s api-extractor:local api-documenter",
2424
"api-extractor": "node generate-reports.js",
2525
"api-extractor:local": "npm run build && node generate-reports.js --local",
2626
"esm-wrap": "node generate-esm-wrapper.js",
27-
"api-documenter": "api-documenter-fire markdown --input temp --output docgen/markdown -s",
27+
"api-documenter": "run-s api-documenter:markdown api-documenter:toc api-documenter:post",
28+
"api-documenter:markdown": "api-documenter-fire markdown --input temp --output docgen/markdown -s",
2829
"api-documenter:toc": "api-documenter-fire toc --input temp --output docgen/markdown -p /docs/reference/admin/node -s",
2930
"api-documenter:post": "node docgen/post-process.js"
3031
},

src/app-check/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { app } from '../firebase-namespace-api';
4242
* @param app Optional app for which to return the `AppCheck` service.
4343
* If not provided, the default `AppCheck` service is returned.
4444
*
45-
* @return The default `AppCheck` service if no
45+
* @returns The default `AppCheck` service if no
4646
* app is provided, or the `AppCheck` service associated with the provided
4747
* app.
4848
*/
@@ -59,10 +59,10 @@ export namespace appCheck {
5959
/**
6060
* Creates a new {@link appCheck.AppCheckToken `AppCheckToken`} that can be sent
6161
* back to a client.
62-
*
62+
*
6363
* @param appId The App ID of the Firebase App the token belongs to.
6464
*
65-
* @return A promise that fulfills with a `AppCheckToken`.
65+
* @returns A promise that fulfills with a `AppCheckToken`.
6666
*/
6767
createToken(appId: string): Promise<AppCheckToken>;
6868

@@ -73,7 +73,7 @@ export namespace appCheck {
7373
*
7474
* @param appCheckToken The App Check token to verify.
7575
*
76-
* @return A promise fulfilled with the
76+
* @returns A promise fulfilled with the
7777
* token's decoded claims if the App Check token is valid; otherwise, a rejected
7878
* promise.
7979
*/
@@ -146,7 +146,7 @@ export namespace appCheck {
146146
app_id: string;
147147
[key: string]: any;
148148
}
149-
149+
150150
/**
151151
* Interface representing a verified App Check token response.
152152
*/

0 commit comments

Comments
 (0)