Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: backlinks from example manifests to guides #1177

Merged

Conversation

markmc
Copy link
Contributor

@markmc markmc commented May 31, 2022

Fixes #446

Based on #1083

We would like our example YAML files to include comments that do not show up in the guides where the files are used as jinja templates, while still ensuring they are valid YAML files.

Configuring the jinja Environment with "line_comment_prefix" allows you to control the syntax of the jinja comment directive. If we set that to "##", then such lines are ommitted during jinja templating, and are treated as YAML comments.

See also https://jinja.palletsprojects.com/en/2.11.x/templates/#line-statements

Generated the comments using this awfulness:

$ sed -i '1s/^/## Used in:\n/' $( \
    for iii in $(git grep -l '{% include' site-src/); do \
      awk -F "'" '/{% include/ { print "examples/"$2 }' $iii ; \
    done | sort | uniq)

$ for iii in $(git grep -l '{% include' site-src/); do \
    for jjj in $(awk -F "'" '/{% include/ { print "examples/"$2 }' $iii); do \
      sed -i "2s|^|## - $iii\n|" $jjj; \
    done; \
  done

/kind documentation

markmc and others added 2 commits May 31, 2022 17:50
We would like our example YAML files to include comments that do not
show up in the guides where the files are used as jinja templates,
while still ensuring they are valid YAML files.

Configuring the jinja Environment with "line_comment_prefix" allows
you to control the syntax of the jinja comment directive. If we set
that to "##", then such lines are ommitted during jinja templating,
and are treated as YAML comments.

See also
https://jinja.palletsprojects.com/en/2.11.x/templates/#line-statements
Add Jinja "line comments" to our example manifests which reference the
guides which use them.

Generated using this awfulness:

$ sed -i '1s/^/## Used in:\n/' $( \
    for iii in $(git grep -l '{% include' site-src/); do \
      awk -F "'" '/{% include/ { print "examples/"$2 }' $iii ; \
    done | sort | uniq)

$ for iii in $(git grep -l '{% include' site-src/); do \
    for jjj in $(awk -F "'" '/{% include/ { print "examples/"$2 }' $iii); do \
      sed -i "2s|^|## - $iii\n|" $jjj; \
    done; \
  done

Co-authored-by: Mark McLoughlin <[email protected]>
@k8s-ci-robot k8s-ci-robot added kind/documentation Categorizes issue or PR as related to documentation. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 31, 2022
@k8s-ci-robot k8s-ci-robot requested review from bowei and jpeach May 31, 2022 17:39
@robscott
Copy link
Member

This is brilliant, thanks @markmc! I'd love to see some automation around adding these comments in the future, but this is already a great upgrade as is.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 31, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markmc, robscott

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 31, 2022
@k8s-ci-robot k8s-ci-robot merged commit d48f7c4 into kubernetes-sigs:master May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add backlinks from example manifests to guides
4 participants