* Validates (sort of) an `mkdocs.yml` config file. * * It checks if the file exists, if it can be parsed as YAML, and if it has a `site_name` property.
()
| 281 | * It checks if the file exists, if it can be parsed as YAML, and if it has a `site_name` property. |
| 282 | */ |
| 283 | protected async validateMkDocsConfig() { |
| 284 | log.debug(`Validating ${NAME_MKDOCS_YML}`); |
| 285 | |
| 286 | const mkDocsYmlPath = this.mkDocsYmlPath ?? (await findMkDocsYml(this.cwd)); |
| 287 | if (!mkDocsYmlPath) { |
| 288 | return this.fail(`Could not find ${NAME_MKDOCS_YML} from ${this.cwd}; please run "${NAME_BIN} init"`); |
| 289 | } |
| 290 | |
| 291 | let mkDocsYml: MkDocsYml; |
| 292 | try { |
| 293 | mkDocsYml = await readMkDocsYml(mkDocsYmlPath); |
| 294 | } catch (e) { |
| 295 | const err = e as NodeJS.ErrnoException; |
| 296 | if (err.code === NAME_ERR_ENOENT) { |
| 297 | return this.fail( |
| 298 | `Could not find ${NAME_MKDOCS_YML} at ${mkDocsYmlPath}. Use --mkdocs-yml to specify a different path.`, |
| 299 | ); |
| 300 | } |
| 301 | return this.fail(`Could not parse ${mkDocsYmlPath}: ${err}`); |
| 302 | } |
| 303 | |
| 304 | if (!mkDocsYml.site_name) { |
| 305 | return this.fail(`Could not find required property "site_name" in ${mkDocsYmlPath}`); |
| 306 | } |
| 307 | |
| 308 | this.ok(`MkDocs config at ${mkDocsYmlPath} OK`); |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Asserts that the dependencies as listed in `requirements.txt` are installed. |