mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
The documentation site's domain has expired and its pages described a 2021 v2rayA. The page now carries its own docs, written against the current code and shipped with the build, so what a user reads matches the binary they run: quick start, transparent proxy, routing rules, inbounds and sharing, flags and environment, troubleshooting. English and Simplified Chinese; the other locales read the English text and say so. The sections are Markdown under gui/src/docs/<locale>/, compiled to HTML at build time by a small vite plugin around marked (a devDependency; the bundle carries no parser) and loaded on demand, so the first load does not grow. Headings get ids from their text. The flag table is not written by hand: GET /api/params reads conf.Params' struct tags (id, short, default, desc) through reflection, the same tags gonfig parses, and the page renders it, so a new flag documents itself. "#docs" and "#docs/<section>" open the page; the RoutingA dialog's help button, the About page and small book icons in the settings sections and the inbound dialogs point there instead of at the dead site or the wiki. The navigation gains a fifth destination.
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package conf
|
|
|
|
import (
|
|
"reflect"
|
|
"strings"
|
|
)
|
|
|
|
// Param describes one command-line flag of v2rayA for the documentation
|
|
// page: the flag, its environment variable, its default and the help text.
|
|
type Param struct {
|
|
Flag string `json:"flag"`
|
|
Short string `json:"short"`
|
|
Env string `json:"env"`
|
|
Default string `json:"default"`
|
|
Desc string `json:"desc"`
|
|
}
|
|
|
|
// Parameters lists the flags in Params in declaration order, read from the
|
|
// same struct tags gonfig parses, so the documentation cannot drift from
|
|
// what the binary accepts. Fields tagged ignore:"1" are one-shot commands
|
|
// (--version, --reset-password) or hidden switches and are included with
|
|
// their description when they have one.
|
|
func Parameters() []Param {
|
|
t := reflect.TypeOf(Params{})
|
|
params := make([]Param, 0, t.NumField())
|
|
for i := 0; i < t.NumField(); i++ {
|
|
f := t.Field(i)
|
|
id := f.Tag.Get("id")
|
|
if id == "" {
|
|
continue
|
|
}
|
|
desc := f.Tag.Get("desc")
|
|
if desc == "" && f.Tag.Get("ignore") != "" {
|
|
continue
|
|
}
|
|
params = append(params, Param{
|
|
Flag: "--" + id,
|
|
Short: f.Tag.Get("short"),
|
|
Env: "V2RAYA_" + strings.ToUpper(strings.ReplaceAll(id, "-", "_")),
|
|
Default: f.Tag.Get("default"),
|
|
Desc: desc,
|
|
})
|
|
}
|
|
return params
|
|
}
|