* This file creates a folder full of docusaurus markdown files for https://unpackerr.zip */
(config *Config, output string)
| 16 | /* This file creates a folder full of docusaurus markdown files for https://unpackerr.zip */ |
| 17 | |
| 18 | func createDocusaurus(config *Config, output string) { |
| 19 | // Generate index file first. |
| 20 | if err := makeGenerated(config, output); err != nil { |
| 21 | log.Fatalln(err) |
| 22 | } |
| 23 | // Loop the 'Order' list. |
| 24 | for _, section := range config.Order { |
| 25 | // If Order contains a missing section, bail. |
| 26 | if config.Sections[section] == nil { |
| 27 | log.Fatalln(section + ": in order, but missing from sections. This is a bug in definitions.yml.") |
| 28 | } |
| 29 | // We only care about sections with parameters defined. |
| 30 | if len(config.Sections[section].Params) < 1 { |
| 31 | continue |
| 32 | } |
| 33 | |
| 34 | if config.Defs[section] != nil { |
| 35 | // Repeat this section based on defined definitions. |
| 36 | data := config.Sections[section].makeDefinedDocs(config.Prefix, config.Defs[section], config.DefOrder[section]) |
| 37 | if err := writeDocusaurus(output, string(section), data); err != nil { |
| 38 | log.Fatalln(err) |
| 39 | } |
| 40 | } else { |
| 41 | data := config.Sections[section].makeDocs(config.Prefix, section) |
| 42 | if err := writeDocusaurus(output, string(section), data); err != nil { |
| 43 | log.Fatalln(err) |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func writeDocusaurus(dir, file, content string) error { |
| 50 | _ = os.Mkdir(dir, dirMode) |
no test coverage detected