Feat: add base resource section for component ref (#4635)

* Feat: add base resource section for component ref

Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>

* read from local

Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>

* fix

Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>

* beautify

Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>

* format imports

Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>

Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>
This commit is contained in:
qiaozp
2022-08-20 10:26:39 +08:00
committed by GitHub
parent afb0466bcc
commit 36ee590071
5 changed files with 68 additions and 7 deletions

View File

@@ -61,7 +61,7 @@ func PrintCLIByTag(cmd *cobra.Command, all []*cobra.Command, tag string) string
return result
}
// GenMarkdownTreeForIndex will generate the markdown doc for vela index
// GenMarkdownTreeForIndex will generate the Markdown doc for vela index
func GenMarkdownTreeForIndex(cmd *cobra.Command, dir string) error {
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md"
filename := filepath.Join(dir, basename)

View File

@@ -24,6 +24,8 @@ import (
"strings"
"time"
"k8s.io/klog/v2"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/utils/common"
"github.com/oam-dev/kubevela/references/docgen"
@@ -86,8 +88,14 @@ func ComponentDef(ctx context.Context, c common.Args, path, location *string, de
},
CustomDocHeader: CustomComponentHeaderEN,
}
ref.Remote = &docgen.FromCluster{Namespace: types.DefaultKubeVelaNS}
ref.Local = &docgen.FromLocal{Path: ComponentDefDir}
dm, err := c.GetDiscoveryMapper()
if err != nil {
klog.ErrorS(err, "failed to get discovery mapper")
return
}
ref.DiscoveryMapper = dm
if *path != "" {
ref.I18N = &docgen.En
if strings.Contains(*location, "zh") || strings.Contains(*location, "chinese") {