Add build tools to generate SIGME docs

This commit is contained in:
Jamie Hannaford 2017-04-24 17:19:23 +02:00
parent 2192dbd930
commit ff667b8609
5 changed files with 197 additions and 0 deletions

1
build/Dockerfile Normal file
View File

@ -0,0 +1 @@
FROM golang:1.6-onbuild

19
build/README.md Normal file
View File

@ -0,0 +1,19 @@
# SIG Doc builder
This script will generate the following documentation files:
```
sig-*/README.md
sig-list.md
```
Based off the `sigs.yaml` metadata file.
## How to use
To (re)build documentation for all the SIGs, run these commands:
```bash
docker build -t sigdocs -f build/Dockerfile build
docker run -v $(pwd):/go/src/app sigdocs
```

139
build/app.go Normal file
View File

@ -0,0 +1,139 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"github.com/cbroglie/mustache"
"gopkg.in/yaml.v2"
)
var (
sigsYamlFile = "sigs.yaml"
templateDir = "build"
indexTemplate = fmt.Sprintf("%s/sig_index.mustache", templateDir)
listTemplate = fmt.Sprintf("%s/sig_list.mustache", templateDir)
sigListOutput = "sig-list.md"
sigIndexOutput = "README.md"
)
type Lead struct {
Name string
Company string
GitHub string
}
type Meeting struct {
Day string
UTC string
PST string
Frequency string
}
type Contact struct {
Slack string
MailingList string `yaml:"mailing_list"`
GitHubTeam string `yaml:"github_team"`
}
type Sig struct {
Name string
Dir string
MissionStatement string `yaml:"mission_statement"`
Leads []Lead
Meetings []Meeting
MeetingURL string `yaml:"meeting_url"`
MeetingArchiveURL string `yaml:"meeting_archive_url"`
Contact Contact
}
type SigEntries struct {
Sigs []Sig
}
func dirExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return true, err
}
func createReadmeFiles(ctx SigEntries) error {
template, err := mustache.ParseFile(indexTemplate)
if err != nil {
return err
}
for _, sig := range ctx.Sigs {
data, err := template.Render(sig)
if err != nil {
return err
}
exists, err := dirExists(sig.Dir)
if err != nil {
return err
}
if !exists {
err = os.Mkdir(sig.Dir, 0755)
if err != nil {
return err
}
}
err = ioutil.WriteFile(fmt.Sprintf("%s/%s", sig.Dir, sigIndexOutput), []byte(data), 0644)
if err != nil {
return err
}
}
return nil
}
func createListFile(ctx SigEntries) error {
template, err := mustache.ParseFile(listTemplate)
if err != nil {
return err
}
data, err := template.Render(ctx)
if err != nil {
return err
}
err = ioutil.WriteFile(sigListOutput, []byte(data), 0644)
if err != nil {
return err
}
return nil
}
func main() {
yamlData, err := ioutil.ReadFile(sigsYamlFile)
if err != nil {
log.Fatal(err)
}
var ctx SigEntries
err = yaml.Unmarshal(yamlData, &ctx)
if err != nil {
log.Fatal(err)
}
err = createReadmeFiles(ctx)
if err != nil {
log.Fatal(err)
}
err = createListFile(ctx)
if err != nil {
log.Fatal(err)
}
}

19
build/sig_index.mustache Normal file
View File

@ -0,0 +1,19 @@
# {{Name}} SIG
{{MissionStatement}}
## Meetings
{{#Meetings}}
- [{{Day}}s at {{UTC}} UTC]({{MeetingURL}}) ({{Frequency}})
{{/Meetings}}
Meeting notes and Agenda can be found [here]({{MeetingArchiveURL}}).
## Leads
{{#Leads}}
- [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}}
{{/Leads}}
## Contact
{{#Contact}}
Slack: https://kubernetes.slack.com/messages/{{Slack}}
Mailing list: {{MailingList}}
{{#GitHubTeam}}GitHub Team: https://github.com/kubernetes/teams/{{GitHubTeam}}{{/GitHubTeam}}
{{/Contact}}

19
build/sig_list.mustache Normal file
View File

@ -0,0 +1,19 @@
# SIGs and Working Groups
Most community activity is organized into Special Interest Groups (SIGs),
time bounded Working Groups, and the [community meeting](communication.md#Meeting).
SIGs follow these [guidelines](governance.md) although each of these groups may operate a little differently
depending on their needs and workflow.
Each group's material is in its subdirectory in this project.
When the need arises, a [new SIG can be created](sig-creation-procedure.md)
### Master SIG List
| Name | Leads | Contact | Meetings |
|------|-------|---------|----------|
{{#Sigs}}
|[{{ Name }}]({{ Dir }}/README.md)|{{#Leads}}- [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}}<br>{{/Leads}}|{{#Contact}}- [Slack](https://kubernetes.slack.com/messages/{{Slack}})<br>- [Mailing List]({{MailingList}}){{/Contact}}|{{#Meetings}}- [{{Day}}s at {{UTC}} UTC ({{Frequency}})]({{MeetingURL}})<br>{{/Meetings}}
{{/Sigs}}