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

Support atmos docs generate feature natively #934

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f6b4419
docs generate
Listener430 Jan 13, 2025
273a783
readme buildout using Gomplate 3.x with teml.Exec issue fixed
Listener430 Jan 16, 2025
d599ff4
readme generationggomplate 3.11.8 work,s no terrafor yet
Listener430 Jan 17, 2025
1077a1a
fix for windwos gomplate
Listener430 Jan 18, 2025
d051851
gomodtidy
Listener430 Jan 20, 2025
9a672dc
dependant acceptnace tests fix + draft test cases
Listener430 Jan 21, 2025
38060c9
Update internal/exec/docs_generate.go
Listener430 Jan 21, 2025
297e7b3
use go-getter to download files
Listener430 Jan 21, 2025
492fa72
atmos.yaml
Listener430 Jan 21, 2025
33545f5
Update cmd/docs_generate.go
Listener430 Jan 22, 2025
f48f17c
examples back
Listener430 Jan 22, 2025
50469c4
terrafrom test/mergo
Listener430 Jan 22, 2025
9268c2b
moving fixtures to tests and reverting back the comments in template …
Listener430 Jan 23, 2025
77db177
test cases
Listener430 Jan 23, 2025
6bad4f7
initial version of documentation
Listener430 Jan 23, 2025
7e7a8d7
mdx fixes
Listener430 Jan 23, 2025
87f7a56
mdx layout fix
Listener430 Jan 23, 2025
e385bad
typo fix
Listener430 Jan 25, 2025
b023067
defer removeTempDir move
Listener430 Jan 25, 2025
962e741
Update tests/test-cases/docs-generate.yaml
Listener430 Jan 28, 2025
b802e06
Update tests/test-cases/docs-generate.yaml
Listener430 Jan 28, 2025
ead222b
Update tests/test-cases/docs-generate.yaml
Listener430 Jan 28, 2025
a07feaf
Update tests/test-cases/docs-generate.yaml
Listener430 Jan 28, 2025
84f7938
Update tests/test-cases/docs-generate.yaml
Listener430 Jan 28, 2025
0a7092c
Update tests/test-cases/docs-generate.yaml
Listener430 Jan 28, 2025
c511012
Update tests/test-cases/docs-generate.yaml
Listener430 Jan 28, 2025
849ed76
comments from pr
Listener430 Jan 28, 2025
2a45a1e
deleted README.md.gotmpl from the root
Listener430 Jan 28, 2025
3426aeb
terraform test template
Listener430 Jan 28, 2025
711d791
local atmos.yaml
Listener430 Jan 28, 2025
b2cf200
Update pkg/schema/schema.go
Listener430 Jan 29, 2025
b548578
Update cmd/docs_generate.go
Listener430 Jan 29, 2025
50f7c36
Update internal/exec/template_utils.go
Listener430 Jan 29, 2025
43b0c35
Update internal/exec/file_utils.go
Listener430 Jan 29, 2025
142a094
Update internal/exec/template_utils.go
Listener430 Jan 29, 2025
47cedfb
Update internal/exec/file_utils.go
Listener430 Jan 29, 2025
b4b7579
changing func signatures
Listener430 Jan 29, 2025
eaf1f1e
test cases
Listener430 Jan 29, 2025
1c19bc2
Merge branch 'main' into DEV-2835
Listener430 Jan 29, 2025
8e1398c
Tidy go.mod and go.sum
Listener430 Jan 29, 2025
bbbaf4d
comments
Listener430 Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions atmos.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be modifying the root atmos.yaml for testing. Instead, please use fixtures

Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,26 @@ settings:
color: "${colors.muted}"
italic: true


docs:
generate:
input:
- "./README.yaml"
# To Do: template can be a remote URL/github, using this local for testing
template: "https://raw.githubusercontent.com/cloudposse/.github/5a599e3b929f871f333cb9681a721d26b237d8de/README.md.gotmpl"
# The final README
output: "README.md"
terraform:
enabled: true
format: "markdown"
show_providers: false
show_inputs: true
show_outputs: true
sort_by: "name"
hide_empty: false
indent_level: 2
Comment on lines +393 to +409
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docs:
generate:
input:
- "./README.yaml"
# To Do: template can be a remote URL/github, using this local for testing
template: "https://raw.githubusercontent.com/cloudposse/.github/5a599e3b929f871f333cb9681a721d26b237d8de/README.md.gotmpl"
# The final README
output: "README.md"
terraform:
enabled: true
format: "markdown"
show_providers: false
show_inputs: true
show_outputs: true
sort_by: "name"
hide_empty: false
indent_level: 2
docs:
generate:
# Generate README in current working directory
readme:
directories:
- .
input:
- "./README.yaml"
# To Do: template can be a remote URL/github, using this local for testing
template: "https://raw.githubusercontent.com/cloudposse/.github/5a599e3b929f871f333cb9681a721d26b237d8de/README.md.gotmpl"
# The final README
output: "README.md"
terraform:
enabled: true
format: "markdown"
show_providers: false
show_inputs: true
show_outputs: true
sort_by: "name"
hide_empty: false
indent_level: 2
components: # free form name, could be anything.
directories:
- components/terraform/**/
input:
- README.yaml
# To Do: template can be a remote URL/github, using this local for testing
template: "https://raw.githubusercontent.com/cloudposse/.github/5a599e3b929f871f333cb9681a721d26b237d8de/README.md.gotmpl"
# The final README
output:
- README.md
terraform:
enabled: true
format: "markdown"
show_providers: false
show_inputs: true
show_outputs: true
sort_by: "name"
hide_empty: false
indent_level: 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# generate docs in the current directory
atmos docs generate readme

# generate all docs for components
atmos generate docs generate components



version:
check:
enabled: true
Expand Down
41 changes: 41 additions & 0 deletions cmd/docs_generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cmd

import (
"github.com/spf13/cobra"

e "github.com/cloudposse/atmos/internal/exec"
)

// docsGenerateCmd generates README.md
var docsGenerateCmd = &cobra.Command{
Use: "generate [path]",
Aliases: []string{"docs"},
Short: "Generate docs (README.md) from README.yaml data and templates",
Long: `Generate documentation by merging multiple README.yaml data sources
and then using templates to produce README.md files. Also supports terraform-docs injection.`,
Listener430 marked this conversation as resolved.
Show resolved Hide resolved
Example: `Generate a README.md in the current path:
atmos docs generate

Generate a README.md for the VPC component:
atmos docs generate components/terraform/vpc

Generate all README.md (recursively searches for README.yaml to rebuild docs):
atmos docs generate --all`,
RunE: func(cmd *cobra.Command, args []string) error {
return e.ExecuteDocsGenerateCmd(cmd, args)
},
}

// generateDocsCmd is a new top-level command so we can do `atmos generate docs`.
var generateDocsCmd = &cobra.Command{
Use: "generate",
Short: "Generic generation commands (e.g. docs, scaffolding, etc.)",
Long: `A collection of subcommands for generating artifacts such as documentation or code.`,
}

func init() {
docsGenerateCmd.Flags().Bool("all", false, "Recursively rebuild README.md files from any discovered README.yaml")
docsCmd.AddCommand(docsGenerateCmd)
RootCmd.AddCommand(generateDocsCmd)
generateDocsCmd.AddCommand(docsGenerateCmd)
}
19 changes: 12 additions & 7 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading