Merge pull request #21403 from hainenber/support-additional-mkdocs-server-cli-params

Support additional mkdocs server cli params
This commit is contained in:
Andre Wanlin
2023-11-24 10:31:55 -06:00
committed by GitHub
7 changed files with 56 additions and 0 deletions
@@ -294,6 +294,21 @@ export function registerCommands(program: Command) {
'-c, --mkdocs-config-file-name <FILENAME>',
'Mkdocs config file name',
)
.option(
'--mkdocs-parameter-clean',
'Pass "--clean" parameter to mkdocs server running in containerized environment',
false,
)
.option(
'--mkdocs-parameter-dirtyreload',
'Pass "--dirtyreload" parameter to mkdocs server running in containerized environment',
false,
)
.option(
'--mkdocs-parameter-strict',
'Pass "--strict" parameter to mkdocs server running in containerized environment',
false,
)
.hook('preAction', command => {
if (
command.opts().previewAppPort !== defaultPreviewAppPort &&
@@ -116,6 +116,9 @@ export default async function serve(opts: OptionValues) {
stdoutLogFunc: mkdocsLogFunc,
stderrLogFunc: mkdocsLogFunc,
mkdocsConfigFileName: mkdocsYmlPath,
mkdocsParameterClean: opts.mkdocsParameterClean,
mkdocsParameterDirtyReload: opts.mkdocsParameterDirtyReload,
mkdocsParameterStrict: opts.mkdocsParameterStrict,
});
// Wait until mkdocs server has started so that Backstage starts with docs loaded
@@ -97,6 +97,24 @@ describe('runMkdocsServer', () => {
expect.objectContaining({}),
);
});
it('should accept additinoal mkdocs CLI parameters', async () => {
await runMkdocsServer({
mkdocsParameterClean: true,
mkdocsParameterStrict: true,
});
expect(run).toHaveBeenCalledWith(
'docker',
expect.arrayContaining([
'serve',
'--dev-addr',
'0.0.0.0:8000',
'--clean',
'--strict',
]),
expect.objectContaining({}),
);
});
});
describe('mkdocs', () => {
@@ -26,6 +26,9 @@ export const runMkdocsServer = async (options: {
stdoutLogFunc?: LogFunc;
stderrLogFunc?: LogFunc;
mkdocsConfigFileName?: string;
mkdocsParameterClean?: boolean;
mkdocsParameterDirtyReload?: boolean;
mkdocsParameterStrict?: boolean;
}): Promise<ChildProcess> => {
const port = options.port ?? '8000';
const useDocker = options.useDocker ?? true;
@@ -55,6 +58,9 @@ export const runMkdocsServer = async (options: {
...(options.mkdocsConfigFileName
? ['--config-file', options.mkdocsConfigFileName]
: []),
...(options.mkdocsParameterClean ? ['--clean'] : []),
...(options.mkdocsParameterDirtyReload ? ['--dirtyreload'] : []),
...(options.mkdocsParameterStrict ? ['--strict'] : []),
],
{
stdoutLogFunc: options.stdoutLogFunc,
@@ -72,6 +78,9 @@ export const runMkdocsServer = async (options: {
...(options.mkdocsConfigFileName
? ['--config-file', options.mkdocsConfigFileName]
: []),
...(options.mkdocsParameterClean ? ['--clean'] : []),
...(options.mkdocsParameterDirtyReload ? ['--dirtyreload'] : []),
...(options.mkdocsParameterStrict ? ['--strict'] : []),
],
{
stdoutLogFunc: options.stdoutLogFunc,