-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Added support of readme generation #35
Conversation
modules/docs/Makefile.docs
Outdated
.PHONY : docs\:build | ||
## Create README.md by building it from .README.md file | ||
docs\:build: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be called build-readme
since it's very specific to readme. Or docs:
should be renamed to readme:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
What do you think about a |
modules/docs/Makefile.docs
Outdated
.PHONY : docs\:make | ||
## Cleanup placeholders in README.md | ||
docs\:make: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the make
target name as it's overloading the meaning of make
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Seems like the |
templates/docs/sections.yml
Outdated
@@ -0,0 +1,43 @@ | |||
--- | |||
warning: |- | |||
<!--------------------------------DO NOT EDIT README.md--------------------------------> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<!---
--- This file was automatically generated by the `build-harness`
--- Make changes instead to `.README.md` and rebuild.
--->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
README.md
Outdated
@@ -63,14 +65,20 @@ Available targets: | |||
help This help screen | |||
jenkins:run-job-with-tag Run a Jenkins Job with $(TAG) | |||
make:lint Lint all makefiles | |||
readme:build Create README.md by building it from .README.md file | |||
readme:deps Install dependencies | |||
readme:init Create basic minimalistic .README.md template file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize a minimalistic README.md from template file
README.md
Outdated
@@ -63,14 +65,20 @@ Available targets: | |||
help This help screen | |||
jenkins:run-job-with-tag Run a Jenkins Job with $(TAG) | |||
make:lint Lint all makefiles | |||
readme:build Create README.md by building it from .README.md file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generate README.md from template file
templates/readme/terraform.yml
Outdated
output: |- | ||
## Output | ||
|
||
<!--------------------------------REQUIRE POSTPROCESSING--------------------------------> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What sort of postprocessing?
modules/terraform/Makefile.docs
Outdated
endef | ||
|
||
define terraform_data-docs-prepare-data | ||
$(shell $(TERRAFORM_DOCS) json . > /tmp/terraform_data.json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/terraform_data.json/terraform-docs.json/
modules/readme/Makefile.docs.repo
Outdated
--datasource repo_data=file:///tmp/repo_data.yml | ||
endef | ||
|
||
define repo-docs-prepare-data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what this does
modules/readme/Makefile.docs.repo
Outdated
endef | ||
|
||
define repo_data-docs-provide | ||
--datasource repo_data=file:///tmp/repo_data.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the reliance on /tmp
without a tmp directory. If we're usnig this in multiple projects, there will be collisions.
modules/docs/Makefile
Outdated
.PHONY : docs\:build | ||
## Create $OUT file by building it from $IN template file | ||
docs\:build: | ||
@BUILD_HARNESS_PATH=$(BUILD_HARNESS_PATH) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already exported, so should need to be passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I remove pass $BUILD_HARNESS_PATH
I got this error
2017/12/04 15:34:19 Can't read /home/goruha/projects/cloudposse/build-harness/: &os.PathError{Op:"read", Path:"/home/goruha/projects/cloudposse/build-harness/", Err:0x15}
README.md doc generated
modules/docs/Makefile
Outdated
## Create $OUT file by building it from $IN template file | ||
docs\:build: | ||
@BUILD_HARNESS_PATH=$(BUILD_HARNESS_PATH) \ | ||
GOMPLATE=$(GOMPLATE) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just export it above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have example for that?
modules/git/docs/module.sh
Outdated
} | ||
|
||
function git_data-docs-cleanup-data { | ||
rm -rf $GIT_DATA_FILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-f
should be good enough and safer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
modules/readme/Makefile.docs
Outdated
## Create README.md by building it from .README.md file | ||
readme\:build: | ||
@IN=$(README_TEMPLATE_FILE) \ | ||
OUT=$(README_FILE) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalize whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
modules/terraform/docs/module.sh
Outdated
|
||
|
||
function terraform-docs-prepare-data { | ||
if [ ! -s /usr/local/bin/$TERRAFORM_DOCS ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalize whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Makefile
Outdated
@@ -1,6 +1,6 @@ | |||
BUILD_HARNESS_PATH ?= . | |||
BUILD_HARNESS_PATH ?= $(shell 'pwd') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
modules/docs/Makefile
Outdated
REPO=$(GOMPLATE_REPO) \ | ||
FILE=$(GOMPLATE)_$(OS)-amd64 \ | ||
VERSION=$(GOMPLATE_VERSION) \ | ||
OUTPUT=/usr/local/bin/$(GOMPLATE) > /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should install to a path relative to the build-harness
a) avoids permission issues
b) avoids conflicts between different build-harness
checkouts
What
make
&terraform
projects)Why
How to use
Makefile
in repo root dir ( Example https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment/blob/feature-support-readme-generation/Makefile )$ make readme:init
to fetch basic.README.md
.README.md
template as you need$ make readme:build
to generateREADME.md
based on.README.md
Avaliable placeholders
{{ (datasource "git").name }}
- Repository name{{ (datasource "git").url }}
- Repository URL{{ (datasource "section").help }}
- Cloudpossecontact us
text{{ (datasource "section").contributing }}
- Cloudpossecode of conduct
rules{{ (datasource "license").apache2 }}
- Cloudposseshort license
text{{ (datasource "section").about }}
- Cloudposseabout
text{{ (datasource "section").warning }}
- WarningDO NOT EDIT README.md
{{- (datasource "contributor").erik }}
- Erik's contributor card{{- (datasource "contributor").igor }}
- Igor's contributor card{{- (datasource "contributor").andrew }}
- Andrew contributor card{{- (datasource "contributor").konstantin }}
- Konstantin's contributor card{{- (datasource "contributor").sergey }}
- Sergey's contributor card{{- (datasource "contributor").valeriy }}
- Valeriy's contributor card{{- (datasource "contributor").vladimir }}
- Vladimir's contributor card{{- (datasource "contributor")._links }}
- Links to github profiles and images to contributors (Required if at least one contributor specified in README){{ (datasource "terraform").input }}
- Terraform module input variables table{{ (datasource "terraform").output }}
- Terraform module outputs table{{ (datasource "make").help }}
- Make targets list with descriptions (based onmake help
)Under the hood
Example
cloudposse/terraform-aws-elastic-beanstalk-environment#19
#35