Skip to content

Commit

Permalink
Added CHANGELOG per component (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdmytriv authored Aug 18, 2023
1 parent 33e3875 commit f009f6a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/website-deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ jobs:
run: |
./scripts/render-docs-for-components.sh
- name: "Render Documentation for Terraform Components Change Log"
- name: "Copy Upgrade Guide"
run: |
./scripts/render-docs-for-changelog.sh
./scripts/copy-upgrade-guide.sh
- name: "Render Documentation for Terraform Modules"
env:
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions scripts/docs-collator/ComponentRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from utils import io, rendering, templating

README_MD = 'README.md'
CHANGELOG_MD = 'CHANGELOG.md'
GITHUB_REPO = 'cloudposse/terraform-aws-components'
INDEX_CATEGORY_JSON = '_category_.json'

Expand All @@ -29,10 +30,16 @@ def render(self, component):

def __render_doc(self, component, file):
module_download_dir = os.path.join(self.download_dir, 'modules')

content = io.read_file_to_string(file)
content = rendering.fix_self_non_closing_br_tags(content)
content = rendering.fix_custom_non_self_closing_tags_in_pre(content)
content = rendering.remove_logo_from_the_bottom(content)

change_log_file = os.path.join(os.path.dirname(file), CHANGELOG_MD)
change_log_content = io.read_file_to_string(change_log_file) if os.path.exists(change_log_file) else ''
change_log_content = rendering.shift_headings(change_log_content)

relative_path = os.path.relpath(file, module_download_dir)
result_file = os.path.join(self.docs_dir, os.path.relpath(file, module_download_dir)) # <module-name>/README.md

Expand All @@ -56,6 +63,7 @@ def __render_doc(self, component, file):
doc_content = DOC_TEMPLATE.render(label=label,
title=title,
content=content,
change_log_content=change_log_content,
github_repository=GITHUB_REPO,
github_edit_url=github_edit_url,
tags=tags)
Expand Down
4 changes: 4 additions & 0 deletions scripts/docs-collator/templates/components/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ tags: [{{ tags|join(', ') }}]
---

{{ content }}

## CHANGELOG

{{ change_log_content }}
31 changes: 31 additions & 0 deletions scripts/docs-collator/utils/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@ def fix_custom_non_self_closing_tags_in_pre(content):
return '\n'.join(fixed_lines)


def shift_headings(content):
lines = content.splitlines()
fixed_lines = []
shift_by = 0

# figuring out how much to shift headings to the right so the biggest heading is H3
for line in lines:
if re.match(r'^#\s+', line): # we have to shift all headings by 2
shift_by = 2
break

if re.match(r'^##\s+', line): # we have to shift all headings by 1
shift_by = 1
break

if shift_by == 0:
return content

for line in lines:
if not line.startswith('#'): # not a heading
fixed_lines.append(line)
continue

if shift_by == 1:
fixed_lines.append(f"#{line}")
elif shift_by == 2:
fixed_lines.append(f"##{line}")

return '\n'.join(fixed_lines)


def fix_sidebar_label(content, repo):
provider, module_name = parse_terraform_repo_name(repo.name)
return SIDEBAR_LABEL_REGEX.sub(f'sidebar_label: {module_name}', content)
Expand Down
4 changes: 2 additions & 2 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ nav.navbar {
}
*/

.menu__link {
/* .menu__link {
order: 1;
}
} */

.menu__caret:before {
background: var(--ifm-menu-link-sublist-icon) 50% / 2rem 1.5rem;
Expand Down

0 comments on commit f009f6a

Please sign in to comment.