mirror of
https://github.com/filecoin-project/lotus.git
synced 2025-08-25 01:45:12 +08:00
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"github.com/filecoin-project/lotus/cli/lotus"
|
|
"github.com/filecoin-project/lotus/cli/miner"
|
|
"github.com/filecoin-project/lotus/cli/worker"
|
|
)
|
|
|
|
const (
|
|
outputDir = "documentation/en"
|
|
depthRecursionLimit = 1024
|
|
)
|
|
|
|
func main() {
|
|
// Unset environment variables to avoid interference.
|
|
for _, e := range []string{
|
|
"LOTUS_PATH",
|
|
"LOTUS_MINER_PATH",
|
|
"LOTUS_STORAGE_PATH",
|
|
"LOTUS_WORKER_PATH",
|
|
"LOTUS_PANIC_REPORT_PATH",
|
|
"WALLET_PATH",
|
|
"WORKER_PATH",
|
|
} {
|
|
if err := os.Unsetenv(e); err != nil {
|
|
fmt.Printf("Failed to unset %s: %v\n", e, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// Skip commit suffix in version commands.
|
|
if err := os.Setenv("LOTUS_VERSION_IGNORE_COMMIT", "1"); err != nil {
|
|
fmt.Printf("Failed to set LOTUS_VERSION_IGNORE_COMMIT: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Make sure output directory exists.
|
|
if err := os.MkdirAll(outputDir, os.ModePerm); err != nil {
|
|
fmt.Printf("Failed to create %s: %v\n", outputDir, err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Println("Generating CLI documentation...")
|
|
|
|
cliApps := map[string]*cli.App{
|
|
"lotus": lotus.App(),
|
|
"lotus-worker": worker.App(),
|
|
"lotus-miner": miner.App(),
|
|
}
|
|
|
|
for name, app := range cliApps {
|
|
for _, cmd := range app.Commands {
|
|
cmd.HelpName = fmt.Sprintf("%s %s", app.HelpName, cmd.Name)
|
|
}
|
|
|
|
generator := NewDocGenerator(outputDir, app)
|
|
if err := generator.Generate(name); err != nil {
|
|
fmt.Printf(" ❌ %s: %v\n", name, err)
|
|
continue
|
|
}
|
|
fmt.Printf(" ✅ %s\n", name)
|
|
}
|
|
|
|
fmt.Println("Documentation generation complete.")
|
|
}
|