Skip to content

Commit bca2044

Browse files
authored
Add a vscode extension support (#30)
* Add a vscode extension support * Add missing package cache * Support to render the current template * Fix the wrong output file path * Support to ignore the metadata of templates * Test pass with the basic function * Add instructions about the vscode plugin * Add publisher * Update README.md Co-authored-by: rick <[email protected]>
1 parent 72c091a commit bca2044

File tree

19 files changed

+5282
-0
lines changed

19 files changed

+5282
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ bin/
44
.idea/
55
.vscode/
66
coverage.out
7+
plugins/vscode/yaml-readme/node_modules/
8+
*.vsix
9+
*/**/.DS_Store
10+
.DS_Store

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
build:
22
mkdir -p bin
33
go build -o bin/yaml-readme .
4+
copy: build
5+
cp bin/yaml-readme /usr/local/bin
6+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![codecov](https://codecov.io/gh/LinuxSuRen/yaml-readme/branch/master/graph/badge.svg?token=mnFyeD2IQ7)](https://codecov.io/gh/LinuxSuRen/yaml-readme)
2+
[![vscode](https://vsmarketplacebadge.apphb.com/version/linuxsuren.yaml-readme.svg)](https://marketplace.visualstudio.com/items?itemName=linuxsuren.yaml-readme)
23

34
A helper to generate the READE file automatically.
45

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!yaml-readme -p data/financing/*.yaml --output financing.md
2+
a fake template

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"os"
1515
"os/exec"
1616
"path/filepath"
17+
"regexp"
1718
"sort"
1819
"strconv"
1920
"strings"
@@ -116,6 +117,8 @@ func loadTemplate(templateFile string, includeHeader bool) (readmeTpl string, er
116117
filepath.Base(templateFile), filepath.Base(templateFile))
117118
}
118119
readmeTpl = readmeTpl + string(data)
120+
s, err := regexp.Compile("#!yaml-readme .*\n")
121+
readmeTpl = s.ReplaceAllString(readmeTpl, "")
119122
return
120123
}
121124

main_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,19 @@ func Test_loadTemplate(t *testing.T) {
469469
assert.Nil(t, err)
470470
return true
471471
},
472+
}, {
473+
name: "has metadata",
474+
args: args{
475+
templateFile: "function/data/README-with-metadata.tpl",
476+
includeHeader: false,
477+
},
478+
wantReadmeTpl: func() string {
479+
return `a fake template`
480+
},
481+
wantErr: func(t assert.TestingT, err error, i ...interface{}) bool {
482+
assert.Nil(t, err)
483+
return true
484+
},
472485
}}
473486
for _, tt := range tests {
474487
t.Run(tt.name, func(t *testing.T) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"commonjs": true,
5+
"es6": true,
6+
"node": true,
7+
"mocha": true
8+
},
9+
"parserOptions": {
10+
"ecmaVersion": 2018,
11+
"ecmaFeatures": {
12+
"jsx": true
13+
},
14+
"sourceType": "module"
15+
},
16+
"rules": {
17+
"no-const-assign": "warn",
18+
"no-this-before-super": "warn",
19+
"no-undef": "warn",
20+
"no-unreachable": "warn",
21+
"no-unused-vars": "warn",
22+
"constructor-super": "warn",
23+
"valid-typeof": "warn"
24+
}
25+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.vscode/**
2+
.vscode-test/**
3+
test/**
4+
.gitignore
5+
.yarnrc
6+
vsc-extension-quickstart.md
7+
**/jsconfig.json
8+
**/*.map
9+
**/.eslintrc.json
10+
node_modules
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
3+
All notable changes to the "yaml-readme" extension will be documented in this file.
4+
5+
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6+
7+
## [Unreleased]
8+
9+
- Initial release

plugins/vscode/yaml-readme/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Rick
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)