Use object for YAML file

Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
Andre Wanlin
2023-01-17 13:20:45 -06:00
committed by Renan Mendes Carvalho
parent 6d612acd95
commit 8e11504ce3
2 changed files with 16 additions and 7 deletions
@@ -26,7 +26,7 @@ import path, { resolve as resolvePath } from 'path';
import { PassThrough, Writable } from 'stream';
import { Logger } from 'winston';
import { ParsedLocationAnnotation } from '../../helpers';
import { SupportedGeneratorKey } from './types';
import { DefaultMkdocsContent, SupportedGeneratorKey } from './types';
import { getFileTreeRecursively } from '../publish/helpers';
// TODO: Implement proper support for more generators.
@@ -169,13 +169,16 @@ export const generateMkdocsYml = async (
const mkdocsYmlPath = path.join(inputDir, 'mkdocs.yml');
const defaultSiteName = siteOptions?.name ?? 'Documentation Site';
const defaultMkdocsContent =
`site_name: ${defaultSiteName}\n` +
'docs_dir: docs\n' +
'plugins:\n' +
' - techdocs-core\n';
const defaultMkdocsContent: DefaultMkdocsContent = {
site_name: defaultSiteName,
docs_dir: 'docs',
plugins: ['techdocs-core'],
};
await fs.writeFile(mkdocsYmlPath, defaultMkdocsContent);
await fs.writeFile(
mkdocsYmlPath,
yaml.dump(defaultMkdocsContent, { schema: MKDOCS_SCHEMA }),
);
} catch (error) {
throw new ForwardedError('Could not generate mkdocs.yml file', error);
}
@@ -91,3 +91,9 @@ export type GeneratorBuilder = {
register(protocol: SupportedGeneratorKey, generator: GeneratorBase): void;
get(entity: Entity): GeneratorBase;
};
export type DefaultMkdocsContent = {
site_name: string;
docs_dir: string;
plugins: String[];
};