Verify that all APIs are documented in unit test
Summary: When exposing new top-level APIs from `flipper-plugin`, they should be documented. Added a unit test to enforce this and added documentation for all missing APIs. Reviewed By: passy Differential Revision: D25421401 fbshipit-source-id: f5cafc1881de846c8a5dd86e5d094ebd27a66f2a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4aff8c1bcf
commit
8dc321c1ee
@@ -7,6 +7,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {readFile} from 'fs';
|
||||
import {promisify} from 'util';
|
||||
import * as FlipperPluginModule from '../index';
|
||||
|
||||
test('Correct top level API exposed', () => {
|
||||
@@ -67,3 +69,21 @@ test('Correct top level API exposed', () => {
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
test('All APIs documented', async () => {
|
||||
const docs = await promisify(readFile)(
|
||||
__dirname + '/../../../../docs/extending/flipper-plugin.mdx',
|
||||
'utf8',
|
||||
);
|
||||
Object.keys(FlipperPluginModule)
|
||||
.filter(
|
||||
(key) =>
|
||||
!key.startsWith('_') && (FlipperPluginModule as any)[key] !== undefined,
|
||||
)
|
||||
.forEach((key) => {
|
||||
// There should be a header with this identifier
|
||||
if (!new RegExp(`# ${key}\\b`).test(docs)) {
|
||||
fail(`Not documented: '${key}'`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user