1 Star 1 Fork 0

Rick / yaml-readme

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

codecov

A helper to generate the READE file automatically.

Get started

Install it via hd:

hd i yaml-readme

Usage

# yaml-readme -h
Usage:
  yaml-readme [flags]

Flags:
  -h, --help              help for yaml-readme
  -p, --pattern string    The glob pattern with Golang spec to find files (default "items/*.yaml")
  -t, --template string   The template file which should follow Golang template spec (default "README.tpl")

Available variables:

Name Usage
filename The filename of a particular item file. For example, items/good.yaml, the filename is good.
parentname The parent directory name. For example, items/good.yaml, the parent name is items.
fullpath The related file path of each items.

Available functions

Name Usage Description
printHelp {{printHelp 'hd'}} Print the help text of a command
printToc {{printToc}} Print the TOC of the template file
printContributors {{printContributors "linuxsuren" "yaml-readme"}} Print all the contributors of an repository
printStarHistory {{printStarHistory "linuxsuren" "yaml-readme"}} Print the star history of an repository `
printVisitorCount {{printVisitorCount "repo-id"}} Print the visitor count chart of an repository `

Ignore particular items

In case you want to ignore some particular items, you can put a key ignore with value true. Let's see the following sample:

name: rick
ignore: true

Use in GitHub actions

You could copy the following sample YAML, and change some variables according to your needs.

name: generator

on:
  push:
    branches: [ master ]

  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, 'ci skip')"

    steps:
      - uses: actions/checkout@v3
      - name: Update readme
        uses: linuxsuren/yaml-readme@v0.0.6
        env:
          GH_TOKEN: ${{ secrets.GH_SECRETS }}
        with:
          pattern: 'config/*/*.yml'
          username: linuxsuren
          org: linuxsuren
          repo: hd-home

Samples

Below is a simple template sample:

The total number of tools is: {{len .}}
| Name | Latest | Download |
|---|---|---|
{{- range $val := .}}
| {{$val.name}} | {{$val.latest}} | {{$val.download}} |
{{- end}}

Below is a grouped data sample:

{{- range $key, $val := .}}
Year: {{$key}}
| Name | Age |
|---|---|
{{- range $item := $val}}
| {{$item.name}} | {{$item.age}} |
{{- end}}
{{end}}

You could use the following command to render it:

yaml-readme --group-by year

Assume there is a complex YAML like this:

metadata:
  annotations:
    group/key: 'a value'

then you can use the following template:

{{index $item.metadata.annotations "group/key"}}
MIT License Copyright (c) 2022 Rick Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A helper to generate the READE file automatically from YAML-based metadata files. 展开 收起
Go 等 4 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/linuxsuren/yaml-readme.git
git@gitee.com:linuxsuren/yaml-readme.git
linuxsuren
yaml-readme
yaml-readme
master

搜索帮助

14c37bed 8189591 565d56ea 8189591