in src/rpdk/core/project.py [0:0]
def generate_docs(self):
if self.artifact_type == ARTIFACT_TYPE_MODULE:
return
# generate the docs folder that contains documentation based on the schema
docs_path = self.root / "docs"
if not self.type_info or not self.schema or "properties" not in self.schema:
LOG.warning(
"Could not generate schema docs due to missing type info or schema"
)
return
LOG.debug("Removing generated docs: %s", docs_path)
shutil.rmtree(docs_path, ignore_errors=True)
docs_path.mkdir(exist_ok=True)
LOG.debug("Writing generated docs")
# take care not to modify the master schema
docs_schema = json.loads(json.dumps(self.schema))
self._flattened_schema = JsonSchemaFlattener(
json.loads(json.dumps(self.schema))
).flatten_schema()
docs_schema["properties"] = {
name: self._set_docs_properties(name, value, (name,))
for name, value in self._flattened_schema[()]["properties"].items()
}
LOG.debug("Finished documenting nested properties")
ref = self._get_docs_primary_identifier(docs_schema)
getatt = self._get_docs_gettable_atts(docs_schema)
readme_path = docs_path / "README.md"
LOG.debug("Writing docs README: %s", readme_path)
template = self.env.get_template("docs-readme.md")
contents = template.render(
type_name=self.type_name, schema=docs_schema, ref=ref, getatt=getatt
)
self.safewrite(readme_path, contents)