Skip to content

Commit

Permalink
docs: updates "update-actions-readmes" to handle newlines
Browse files Browse the repository at this point in the history
Newlines in descriptions caused issues in table formatting

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed May 7, 2024
1 parent 232d2c5 commit 52ac672
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
4 changes: 1 addition & 3 deletions actions/autosync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ name: Example Workflow
| markdown_path | Path relative to the repository path where the Trestle markdown files are located. See action README.md for more information. | None | True |
| oscal_model | OSCAL Model type to assemble. Values can be catalog, profile, compdef, or ssp. | None | True |
| dry_run | Runs tasks without pushing changes to the repository. | false | False |
| github_token | "GitHub token used to make authenticated API requests.
Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token."
| None | False |
| github_token | "GitHub token used to make authenticated API requests. Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token." | None | False |
| version | Version of the OSCAL model to set during assembly into JSON. | None | False |
| skip_assemble | Skip assembly task. Defaults to false | false | False |
| skip_regenerate | Skip regenerate task. Defaults to false. | false | False |
Expand Down
4 changes: 1 addition & 3 deletions actions/create-cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ name: Example Workflow
| component_description | Description of the component to create | None | True |
| filter_by_profile | Name of the profile in the workspace to filter controls by | None | False |
| dry_run | Runs tasks without pushing changes to the repository. | false | False |
| github_token | "GitHub token used to make authenticated API requests.
Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token."
| None | False |
| github_token | "GitHub token used to make authenticated API requests. Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token." | None | False |
| commit_message | Commit message | Sync automatic updates | False |
| pull_request_title | Custom pull request title | Automatic updates from trestlebot | False |
| branch | Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event. | ${{ github.ref_name }} | False |
Expand Down
4 changes: 1 addition & 3 deletions actions/rules-transform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ With custom rules directory:
| --- | --- | --- | --- |
| rules_view_path | Path relative to the repository path where the Trestle rules view files are located. Defaults to `rules/`. | rules/ | False |
| dry_run | Runs tasks without pushing changes to the repository. | false | False |
| github_token | "GitHub token used to make authenticated API requests.
Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token."
| None | False |
| github_token | "GitHub token used to make authenticated API requests. Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token." | None | False |
| skip_items | Comma-separated glob patterns list of content by Trestle name to skip during task execution. For example `compdef_x,compdef_y*,`. | None | False |
| commit_message | Commit message | Sync automatic updates | False |
| pull_request_title | Custom pull request title | Automatic updates from trestlebot | False |
Expand Down
4 changes: 1 addition & 3 deletions actions/sync-upstreams/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ name: Example Workflow
| --- | --- | --- | --- |
| sources | A newline separated list of upstream sources to sync with a repo@branch format. For example, `https://github.com/myorg/myprofiles@main` | None | True |
| dry_run | Runs tasks without pushing changes to the repository. | false | False |
| github_token | "GitHub token used to make authenticated API requests.
Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token."
| None | False |
| github_token | "GitHub token used to make authenticated API requests. Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token." | None | False |
| include_model_names | Comma-separated glob pattern list of model names (i.e. trestle directory name) to include in the sync. For example, `*framework-v2`. Defaults to include all model names. | None | False |
| exclude_model_names | Comma-separated glob pattern of model names (i.e. trestle directory name) to exclude from the sync. For example, `*framework-v1`. Defaults to skip no model names. | None | False |
| skip_validation | Skip validation of the upstream OSCAL content. Defaults to false | false | False |
Expand Down
13 changes: 11 additions & 2 deletions scripts/update_action_readmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,27 @@ def generate_inputs_markdown_table(inputs: Dict[str, Any]) -> str:
"""Generate the Action Inputs markdown table"""
table = "| Name | Description | Default | Required |\n| --- | --- | --- | --- |\n"
for name, input in inputs.items():
table += f"| {name} | {input.get('description', None)} | {input.get('default', None)} | {input.get('required', None)} |\n" # noqa E501
if input_description := input.get('description', None):
input_description = format_descriptions(input_description)
table += f"| {name} | {input_description} | {input.get('default', None)} | {input.get('required', None)} |\n" # noqa E501
return table


def generate_outputs_markdown_table(outputs: Dict[str, Any]) -> str:
"""Generate the Action Outputs markdown table"""
table = "| Name | Description |\n| --- | --- |\n"
for name, output in outputs.items():
table += f"| {name} | {output.get('description', None)} |\n"
if output_description := output.get('description', None):
output_description = format_descriptions(output_description)
table += f"| {name} | {output_description} |\n"
return table


def format_descriptions(description: str) -> str:
"""Ensure descriptions are a single line."""
return " ".join(description.splitlines())


def replace(all_content: str, start: str, end: str, new_content: str) -> str:
"""Replace the content between start (plus a new line) and end with new_content"""
start_line = all_content.find(start)
Expand Down

0 comments on commit 52ac672

Please sign in to comment.