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

Feat: generate docs for reference automatically #4377

Merged
merged 1 commit into from Jul 18, 2022

Conversation

wonderflow
Copy link
Collaborator

@wonderflow wonderflow commented Jul 13, 2022

Signed-off-by: Jianbo Sun jianbo.sjb@alibaba-inc.com

Description of your changes

  1. enhance vela def doc-gen, support for:

    • Generate documentation for ComponentDefinition webservice
    vela def doc-gen webservice -n vela-system
    
    • Generate documentation for local CUE Definition file webservice.cue
     vela def doc-gen webservice.cue
    
  2. add scripts for generate vela built-in reference docs, add some rules for generated docs

https://github.com/kubevela/kubevela.io/pull/857/files#diff-83f8c791b2a42df6f97d94ab7ca7559d6ede1a6dbaa6bc27b2acc2e23e6a37cc

  1. Refactor the code, align with vela show

  2. trim prefix of definition annoatations/label if it has oam.dev suffix, affected labels:

    • "custom.definition.oam.dev/alias.config.oam.dev" => "alias.config.oam.dev"
    • "custom.definition.oam.dev/catalog.config.oam.dev" => "catalog.config.oam.dev"
    • "custom.definition.oam.dev/multi-cluster.config.oam.dev" => "multi-cluster.config.oam.dev"
    • "custom.definition.oam.dev/type.config.oam.dev" => "type.config.oam.dev"
  3. A definition annoation ("definition.oam.dev/example-url") was added, it can be used to describe the definition example file.

Now, a definition can describe itself, for example:

"testdef": {
	type: "component"
	annotations: {
		"definition.oam.dev/example-url": "https://kubevela.io/examples/applications/create-namespace.yaml"
	}
	labels: {}
	description: "K8s-objects allow users to specify raw K8s objects in properties"
	attributes: workload: type: "autodetects.core.oam.dev"
}
template: {
	output: parameter.objects[0]

	outputs: {
		for i, v in parameter.objects {
			if i > 0 {
				"objects-\(i)": v
			}
		}
	}
	parameter: {
		// +usage=A test key
		objects: [...{}]
	}
}

It contains the description as field, examples loaded from that url and parameter specification generated fromtemplate.paramer.

I have:

  • Read and followed KubeVela's contribution process.
  • Related Docs updated properly. In a new feature or configuration option, an update to the documentation is necessary.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Special notes for your reviewer

@codecov
Copy link

codecov bot commented Jul 13, 2022

Codecov Report

Merging #4377 (a519a6c) into master (a519a6c) will not change coverage.
The diff coverage is n/a.

❗ Current head a519a6c differs from pull request most recent head d7d6e1b. Consider uploading reports for the commit d7d6e1b to get more accurate results

@@           Coverage Diff           @@
##           master    #4377   +/-   ##
=======================================
  Coverage   49.46%   49.46%           
=======================================
  Files         283      283           
  Lines       30909    30909           
=======================================
  Hits        15289    15289           
  Misses      13457    13457           
  Partials     2163     2163           
Flag Coverage Δ
apiserver-unittests 39.96% <0.00%> (ø)
core-unittests 56.25% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a519a6c...d7d6e1b. Read the comment docs.

@wonderflow wonderflow marked this pull request as ready for review July 13, 2022 15:37
@lgtm-com
Copy link

lgtm-com bot commented Jul 14, 2022

This pull request introduces 1 alert when merging 6cbb0b9 into e52ae78 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@wonderflow wonderflow force-pushed the doc-gen branch 2 times, most recently from 74a645a to 3956ab9 Compare July 15, 2022 14:11
pkg/utils/load.go Outdated Show resolved Hide resolved
pkg/utils/load.go Outdated Show resolved Hide resolved
@wonderflow wonderflow force-pushed the doc-gen branch 2 times, most recently from 79bd447 to 6a7af6f Compare July 18, 2022 01:47
pkg/definition/definition.go Show resolved Hide resolved
pkg/utils/load.go Show resolved Hide resolved
references/cli/up.go Outdated Show resolved Hide resolved
references/plugins/i18n.go Outdated Show resolved Hide resolved
references/cli/def.go Outdated Show resolved Hide resolved
@wonderflow wonderflow force-pushed the doc-gen branch 3 times, most recently from 905794a to d7d6e1b Compare July 18, 2022 06:27
Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Feat: refactor hardcode example to embd.FS

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: refactor doc gen for general types

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: update generate format

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: generate terraform reference docs

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Feat: add definition reference generate script

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: refine output format

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: remove dup annotation

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: update doc

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: add i18n support

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Feat: add translation

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Feat: add policy definition gen

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: add compatibility for lable Annotation change

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: add more tests

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Feat: allow mark example doc url on annotation

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Fix: align vela show with vela def doc-gen, add vela def show equals with vela show

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
@wonderflow wonderflow merged commit b24e752 into kubevela:master Jul 18, 2022
@wonderflow wonderflow deleted the doc-gen branch July 18, 2022 11:23
@wonderflow wonderflow added the type/docs Improvements or additions to documentation label Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants