Proposal: generate the configuration reference from struct comments

Aperta
#4,710 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
18/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go, json, markdown

Direzione di ricerca

The proposal concerns the option/ Go structs and their doc comments, the hand-written docs/configuration/** pages, docs/schema.json, and the docgen and cmd/internal/generate_docs tooling with the make check_docs target. Before any code, a maintainer must decide whether a pull request in this direction is accepted, since the issue is an open proposal with no reply yet. Done would mean an agreed scope and a generator whose output matches the current reference.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Proposal: generate the configuration reference from struct comments

Hello,

I would like to propose moving the configuration reference to a struct-first model. Before opening a PR I would like to confirm whether this direction is acceptable, because creating a pull request from my fork fails with CreatePullRequest permission errors (403/404).

Background

docs/configuration is currently maintained by hand in parallel with the option/ structs, which causes:

  • drift between fields and documentation (new/renamed/removed fields, changed defaults);
  • duplicated descriptions of shared fields (tls, dial, listen, udp_timeout, …) across pages;
  • hand-written Structure examples that go stale;
  • a second description source in docs/schema.json;
  • Chinese pages drifting from English (headings, wording, leftover sections);
  • documentation prose stored inside page manifests.

Proposal

Make option/ doc comments the single source of truth and generate the reference from them:

  • field descriptions, examples, defaults, enums and deprecation notices live next to the fields;
  • docgen renders docs/configuration/** and docs/schema.json;
  • an audit compares generated pages with the legacy baseline line by line, so the migration does not lose text;
  • make check_docs fails when the generated output is stale;
  • Chinese is maintained only in a locale catalog (prose, plus <Struct>.<key>.heading for localized field headings);
  • manifests only describe page composition (definitions, expansion, example adjustments), with no prose and no empty placeholder objects.

A small annotation vocabulary is used in comments: @Required, @Since, @Deprecated in <version>:, @Default, @Enum, @See, @Example, @Omit, @Omit: <pages>, admonitions (@note, @warning, …), @Doc <key>: for keys without a field (including variant holder fields), @Override <key>: for embedded-field wording, @shared <slug> and @Tag for shared pages/examples.

Current status

Branch: https://github.com/systemhelper-arm64/sing-box/tree/docs-autogen

Commits:

ab0c3f5d docgen: generate configuration reference from struct comments
bfcefbb9 option: document endpoint pages and adopt metadata markers
885c86ea docgen: generate example blocks, origin links, and marker catalog
7e7e5cde option: backfill documentation comments for every configuration field
722eb572 docgen: struct-first documentation generator

Verification:

  • go run ./cmd/internal/generate_docs -check → OK, audit issues: 0
  • make check_docs → pass
  • go test ./docgen → pass (embed overrides, @Doc placement, fence-aware twin heading mapping, implicit definitions, reference option types, ACME schema union)
  • go vet ./docgen/ ./option/, gofmt -l → clean
  • manifests prose: 0, empty objects: 0

Request

  1. Is a pull request acceptable for this direction? If pull requests are limited to collaborators, how should the change be submitted?
  2. Is the proposed scope reasonable (generator + comment backfill + regenerated pages + schema + tests)?
  3. I can split or reduce the change if the size is a concern (for example, landing the generator first and regenerating pages separately).

If this is not the right place for the discussion, please let me know where to move it.

Thank you!

Lingua principale
Go
Stelle
40.4k
Fork
5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SagerNet/sing-box

Tutte le issue di SagerNet/sing-box

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.