Merge pull request #21403 from hainenber/support-additional-mkdocs-server-cli-params
Support additional mkdocs server cli params
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@techdocs/cli': minor
|
||||
---
|
||||
|
||||
support passing additional mkdocs-server CLI parameters (--dirtyreload, --strict and --clean) when run in containerized mode
|
||||
@@ -91,6 +91,9 @@ Options:
|
||||
--docker-option <DOCKER_OPTION...> Extra options to pass to the docker run command, e.g. "--add-host=internal.host:192.168.11.12"
|
||||
(can be added multiple times).
|
||||
--no-docker Do not use Docker, use MkDocs executable in current user environment.
|
||||
--mkdocs-parameter-clean Pass "--clean" parameter to mkdocs server running in containerized environment.
|
||||
--mkdocs-parameter-dirtyreload Pass "--dirtyreload" parameter to mkdocs server running in containerized environment.
|
||||
--mkdocs-parameter-strict Pass "--strict" parameter to mkdocs server running in containerized environment.
|
||||
--mkdocs-port <PORT> Port for MkDocs server to use (default: "8000")
|
||||
--preview-app-bundle-path <PATH_TO_BUNDLE> Preview documentation using a web app other than the included one.
|
||||
--preview-app-port <PORT> Port where the preview will be served.
|
||||
|
||||
@@ -108,6 +108,9 @@ Options:
|
||||
--preview-app-bundle-path <PATH_TO_BUNDLE>
|
||||
--preview-app-port <PORT>
|
||||
-c, --mkdocs-config-file-name <FILENAME>
|
||||
--mkdocs-parameter-clean
|
||||
--mkdocs-parameter-dirtyreload
|
||||
--mkdocs-parameter-strict
|
||||
-h, --help
|
||||
```
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user