mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Automatically generate table-of-contents for markdown
This patch teaches doclint to regenerate table of contents automatically whenever it's needed. This patch: - splits lint.js into lint.js and cli.js - teaches cli.js to generate table-of-contents - removes the test for table-of-contents errors from doclint - adds a test for doclint failing to parse object destructuring in method parameters.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
const fs = require('fs');
|
||||
const markdownToc = require('markdown-toc');
|
||||
const path = require('path');
|
||||
const Documentation = require('./Documentation');
|
||||
const commonmark = require('commonmark');
|
||||
@@ -142,11 +141,7 @@ module.exports = async function(page, dirPath) {
|
||||
let classes = [];
|
||||
let errors = [];
|
||||
for (let filePath of filePaths) {
|
||||
const markdownText = fs.readFileSync(filePath, 'utf8');
|
||||
const newMarkdownText = markdownToc.insert(markdownText);
|
||||
if (markdownText !== newMarkdownText)
|
||||
errors.push('Markdown TOC is outdated, run `yarn generate-toc`');
|
||||
let outline = await MDOutline.create(page, markdownText);
|
||||
let outline = await MDOutline.create(page, fs.readFileSync(filePath, 'utf8'));
|
||||
classes.push(...outline.classes);
|
||||
errors.push(...outline.errors);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user