Show plugin documentation in Flipper

Reviewed By: passy

Differential Revision: D29392524

fbshipit-source-id: 675de1fc070b1b8b22d0b27721c16dbd6f7076ef
This commit is contained in:
Anton Nikolaev
2021-06-29 13:00:18 -07:00
committed by Facebook GitHub Bot
parent e4fb2907fd
commit 9fc85730ba
10 changed files with 78 additions and 0 deletions

View File

@@ -107,6 +107,14 @@ async function buildPlugin() {
packageJson.engines.flipper = minFlipperVersion;
}
packageJson.version = argv.version;
if (await fs.pathExists(path.join(pluginDir, 'docs', 'overview.mdx'))) {
packageJson.publishedDocs = packageJson.publishedDocs ?? {};
packageJson.publishedDocs.overview = true;
}
if (await fs.pathExists(path.join(pluginDir, 'docs', 'setup.mdx'))) {
packageJson.publishedDocs = packageJson.publishedDocs ?? {};
packageJson.publishedDocs.setup = true;
}
await fs.writeJson(packageJsonPath, packageJson, {spaces: 2});
const packCmd = `yarn pack --cwd "${pluginDir}" --filename ${outputFile}`;
execSync(packCmd, {cwd: rootDir, stdio: 'inherit'});

View File

@@ -100,6 +100,11 @@ const argv = yargs
'Will force using the given value as Flipper version, to be able to test logic which is version-dependent. Setting env var "FLIPPER_FORCE_VERSION" is equivalent.',
type: 'string',
},
'local-docs': {
describe:
'[FB-internal only] Use local instance of documentation website for showing embedded plugin docs.',
type: 'boolean',
},
})
.version('DEV')
.help()
@@ -180,6 +185,10 @@ if (argv['force-version']) {
process.env.FLIPPER_FORCE_VERSION = argv['force-version'];
}
if (argv['local-docs']) {
process.env.FLIPPER_DOCS_BASE_URL = 'http://localhost:3001/docs';
}
function looksLikeDevServer(): boolean {
const hn = hostname();
if (/^devvm.*\.facebook\.com$/.test(hn)) {