-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation generation functionality (#367)
* Add initial documentation generation functionality * Add tests for docs generation * Add subproperty pages to docs generation * Adjustments for review comments #367 * Replace os lib with pathlib funcs #367 * Use previously built RefResolver in docs generation #367 * Fix missed pathlib change for docs generation #367 * Slight refactor * Avoid `.join()` in templates; it expects strings only * Use existing functions to decode JSON pointers * Add `.md` to Jinja autoescape settings to prevent HTML injection from e.g. schema descriptions * Also rename templates to correct file-ending of resulting files * Avoid modifying dictionaries in a loop where possible * Check for nested primaryIdentifier * Support nested additionalIdentifiers (but not compound ones) * Make proppath a tuple, so it is immutable * Avoid modifying proppath for type "array" to avoid duplicate propname in proppath * Liberal use of f-strings * Use read-only properties for GetAtt * Update modified function call for write_settings Co-authored-by: Toby Fleming <[email protected]>
- Loading branch information
Showing
11 changed files
with
620 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# {{ type_name }} | ||
{% if schema.description %} | ||
|
||
{{ schema.description }} | ||
{% endif %} | ||
|
||
## Syntax | ||
|
||
To declare this entity in your AWS CloudFormation template, use the following syntax: | ||
|
||
### JSON | ||
|
||
<pre> | ||
{ | ||
"Type" : "{{ type_name }}", | ||
"Properties" : { | ||
{% if schema.properties %} | ||
{% for propname, prop in schema.properties.items() %} | ||
"<a href="#{{ propname.lower() }}" title="{{ propname }}">{{ propname }}</a>" : <i>{{ prop.jsontype }}</i>{% if not loop.last %},{% endif %} | ||
|
||
{% endfor %} | ||
{% endif %} | ||
} | ||
} | ||
</pre> | ||
|
||
### YAML | ||
|
||
<pre> | ||
Type: {{ type_name }} | ||
Properties: | ||
{% if schema.properties %} | ||
{% for propname, prop in schema.properties.items() %} | ||
<a href="#{{ propname.lower() }}" title="{{ propname }}">{{ propname }}</a>: <i>{{ prop.yamltype }}</i> | ||
{% endfor %} | ||
{% endif %} | ||
</pre> | ||
{% if schema.properties %} | ||
|
||
## Properties | ||
|
||
{% for propname, prop in schema.properties.items() %} | ||
#### {{ propname }} | ||
{% if prop.description %} | ||
|
||
{{ prop.description }} | ||
{% endif %} | ||
|
||
_Required_: {% if propname in schema.required %}Yes{% else %}No{% endif %} | ||
|
||
|
||
_Type_: {{ prop.longformtype }} | ||
{% if prop.allowedvalues %} | ||
|
||
_Allowed Values_: {% for allowedvalue in prop.allowedvalues %}<code>{{ allowedvalue }}</code>{% if not loop.last %} | {% endif %}{% endfor %} | ||
|
||
{% endif %} | ||
{% if prop.minLength %} | ||
|
||
_Minimum_: <code>{{ prop.minLength }}</code> | ||
{% endif %} | ||
{% if prop.maxLength %} | ||
|
||
_Maximum_: <code>{{ prop.maxLength }}</code> | ||
{% endif %} | ||
{% if prop.pattern %} | ||
|
||
_Pattern_: <code>{{ prop.pattern }}</code> | ||
{% endif %} | ||
{% if prop.createonly %} | ||
|
||
_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement) | ||
{% else %} | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
{% endif %} | ||
|
||
{% endfor %} | ||
{% endif %} | ||
{% if getatt or ref %} | ||
## Return Values | ||
{% if ref %} | ||
|
||
### Ref | ||
|
||
When you pass the logical ID of this resource to the intrinsic `Ref` function, Ref returns the {{ ref }}. | ||
{% endif %} | ||
{% if getatt %} | ||
|
||
### Fn::GetAtt | ||
|
||
The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values. | ||
|
||
For more information about using the `Fn::GetAtt` intrinsic function, see [Fn::GetAtt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html). | ||
|
||
{% for att in getatt %} | ||
#### {{ att.name }} | ||
{% if att.description %} | ||
|
||
{{ att.description }} | ||
{% endif %} | ||
|
||
{% endfor %} | ||
{% endif %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# {{ type_name }} {{ subproperty_name }} | ||
{% if schema.description %} | ||
|
||
{{ schema.description }} | ||
{% endif %} | ||
|
||
## Syntax | ||
|
||
To declare this entity in your AWS CloudFormation template, use the following syntax: | ||
|
||
### JSON | ||
|
||
<pre> | ||
{ | ||
{% if schema.properties %} | ||
{% for propname, prop in schema.properties.items() %} | ||
"<a href="#{{ propname.lower() }}" title="{{ propname }}">{{ propname }}</a>" : <i>{{ prop.jsontype }}</i>{% if not loop.last %},{% endif %} | ||
|
||
{% endfor %} | ||
{% endif %} | ||
} | ||
</pre> | ||
|
||
### YAML | ||
|
||
<pre> | ||
{% if schema.properties %} | ||
{% for propname, prop in schema.properties.items() %} | ||
<a href="#{{ propname.lower() }}" title="{{ propname }}">{{ propname }}</a>: <i>{{ prop.yamltype }}</i> | ||
{% endfor %} | ||
{% endif %} | ||
</pre> | ||
{% if schema.properties %} | ||
|
||
## Properties | ||
|
||
{% for propname, prop in schema.properties.items() %} | ||
#### {{ propname }} | ||
{% if prop.description %} | ||
|
||
{{ prop.description }} | ||
{% endif %} | ||
|
||
_Required_: {% if propname in schema.required %}Yes{% else %}No{% endif %} | ||
|
||
_Type_: {{ prop.longformtype }} | ||
{% if prop.allowedvalues %} | ||
|
||
_Allowed Values_: {% for allowedvalue in prop.allowedvalues %}<code>{{ allowedvalue }}</code>{% if not loop.last %} | {% endif %}{% endfor %} | ||
|
||
{% endif %} | ||
{% if prop.minLength %} | ||
|
||
_Minimum_: <code>{{ prop.minLength }}</code> | ||
{% endif %} | ||
{% if prop.maxLength %} | ||
|
||
_Maximum_: <code>{{ prop.maxLength }}</code> | ||
{% endif %} | ||
{% if prop.pattern %} | ||
|
||
_Pattern_: <code>{{ prop.pattern }}</code> | ||
{% endif %} | ||
{% if prop.createonly %} | ||
|
||
_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement) | ||
{% else %} | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
{% endif %} | ||
|
||
{% endfor %} | ||
{% endif %} |
Oops, something went wrong.