docs: show current environment on index

This commit is contained in:
“Naeel”
2026-09-03 17:58:13 +03:00
parent a222a0dace
commit 7a25ad8fc9
4 changed files with 36 additions and 8 deletions
@@ -0,0 +1,11 @@
# Current stand in documentation index
The generated resource index now shows the current environment explicitly:
- `Текущий стенд: DEV`
- `Текущий стенд: TEST`
- `Текущий стенд: PROD`
Each index lists only the two other environments with short usage comments. The namespace is passed explicitly to `docs-generator`, so the label is generated from the selected profile rather than inferred in the HTML build.
DEV, TEST, and PROD were regenerated and their individual `index.html` files were published and verified on the VM. The S3 mirror still reports `unexpected EOF`; direct VM transfer was used.
@@ -70,7 +70,7 @@ func WriteFile(path, content string) {
} }
// IndexMD генерирует index.md с группировкой по категориям. // IndexMD генерирует index.md с группировкой по категориям.
func IndexMD(docsDir string, specs []types.ServiceSpec) { func IndexMD(docsDir string, specs []types.ServiceSpec, namespace string) {
catMap := map[string][]types.ServiceSpec{} catMap := map[string][]types.ServiceSpec{}
for _, s := range specs { for _, s := range specs {
cat := serviceCategory(s.Name) cat := serviceCategory(s.Name)
@@ -89,11 +89,22 @@ func IndexMD(docsDir string, specs []types.ServiceSpec) {
var b bytes.Buffer var b bytes.Buffer
b.WriteString("# Ресурсы провайдера\n\n") b.WriteString("# Ресурсы провайдера\n\n")
b.WriteString("## Другие стенды\n\n") standNames := map[string]string{"nubes-dev": "DEV", "nubes-test": "TEST", "nubes": "PROD"}
b.WriteString("Основные страницы документации для проверки конфигураций на других стендах:\n\n") standURLs := map[string]string{
b.WriteString("- [DEV](https://tf-docs.nodejsk8s.dev.nubes.ru/nubes-dev/) — разработка и интеграция.\n") "nubes-dev": "https://tf-docs.nodejsk8s.dev.nubes.ru/nubes-dev/",
b.WriteString("- [TEST](https://tf-docs.nodejsk8s.dev.nubes.ru/nubes-test/) — тестирование перед PROD.\n") "nubes-test": "https://tf-docs.nodejsk8s.dev.nubes.ru/nubes-test/",
b.WriteString("- [PROD](https://tf-docs.nodejsk8s.dev.nubes.ru/nubes/) — рабочий стенд.\n\n") "nubes": "https://tf-docs.nodejsk8s.dev.nubes.ru/nubes/",
}
standComments := map[string]string{"nubes-dev": "разработка и интеграция", "nubes-test": "проверка перед PROD", "nubes": "рабочий стенд"}
b.WriteString(fmt.Sprintf("## Текущий стенд: %s\n\n", standNames[namespace]))
b.WriteString("Ниже доступны две другие среды документации:\n\n")
for otherNamespace, otherName := range standNames {
if otherNamespace == namespace {
continue
}
b.WriteString(fmt.Sprintf("- [%s](%s) — %s.\n", otherName, standURLs[otherNamespace], standComments[otherNamespace]))
}
b.WriteString("\n")
order := []string{"Базы данных", "Очереди", "Хранилище", "K8s", "VMware", "Приложения", "Сеть", "Другие"} order := []string{"Базы данных", "Очереди", "Хранилище", "K8s", "VMware", "Приложения", "Сеть", "Другие"}
for _, cat := range order { for _, cat := range order {
+6 -1
View File
@@ -26,6 +26,7 @@ func main() {
versionFlag := flag.String("version", "", "Provider version for example block") versionFlag := flag.String("version", "", "Provider version for example block")
apiEndpointFlag := flag.String("api-endpoint", "", "API endpoint for example block (required)") apiEndpointFlag := flag.String("api-endpoint", "", "API endpoint for example block (required)")
providerSourceFlag := flag.String("provider-source", "", "Provider source for example block (required)") providerSourceFlag := flag.String("provider-source", "", "Provider source for example block (required)")
namespaceFlag := flag.String("namespace", "", "Documentation namespace (required)")
opsFlag := flag.Bool("ops", false, "Generate per-service operations docs (resources_ops_yaml → docs/.../operations)") opsFlag := flag.Bool("ops", false, "Generate per-service operations docs (resources_ops_yaml → docs/.../operations)")
flag.Parse() flag.Parse()
@@ -57,6 +58,10 @@ func main() {
if providerSource == "" { if providerSource == "" {
panic("--provider-source is required") panic("--provider-source is required")
} }
namespace := *namespaceFlag
if namespace == "" {
panic("--namespace is required")
}
servicesOrder := loadServicesList(servicesList) servicesOrder := loadServicesList(servicesList)
specs := loadSpecs(resourcesDir, servicesOrder) specs := loadSpecs(resourcesDir, servicesOrder)
@@ -78,7 +83,7 @@ func main() {
writers.ResourceDocs(docsDir, spec, version, apiEndpoint, providerSource) writers.ResourceDocs(docsDir, spec, version, apiEndpoint, providerSource)
processedSpecs = append(processedSpecs, spec) processedSpecs = append(processedSpecs, spec)
} }
writers.IndexMD(docsDir, processedSpecs) writers.IndexMD(docsDir, processedSpecs, namespace)
writers.WriteNavFragment(docsDir, processedSpecs) writers.WriteNavFragment(docsDir, processedSpecs)
} }
@@ -119,6 +119,7 @@ ${ROOT_DIR}/TOOLS/bin/docs-generator \
-services "$SERVICES_LIST_PATH" \ -services "$SERVICES_LIST_PATH" \
-version "$VERSION" \ -version "$VERSION" \
-api-endpoint "$DOCS_API_ENDPOINT" \ -api-endpoint "$DOCS_API_ENDPOINT" \
-provider-source "${REGISTRY_HOSTNAME}/${NAMESPACE}/${PROVIDER_NAME}" -provider-source "${REGISTRY_HOSTNAME}/${NAMESPACE}/${PROVIDER_NAME}" \
-namespace "$NAMESPACE"
echo "Resources and docs generated in template format." echo "Resources and docs generated in template format."