mirror of
https://github.com/apache/superset.git
synced 2026-05-08 09:25:56 +00:00
touchups
This commit is contained in:
105
docs/scripts/export_config_metadata.py
Normal file
105
docs/scripts/export_config_metadata.py
Normal file
@@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Export configuration metadata to JSON for documentation generation.
|
||||
|
||||
This script extracts configuration metadata from SupersetConfig and generates
|
||||
JSON files that can be imported into the documentation site.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
|
||||
# Add the superset directory to Python path
|
||||
superset_root = Path(__file__).parent.parent.parent
|
||||
sys.path.insert(0, str(superset_root))
|
||||
|
||||
from superset.config_extensions import SupersetConfig # noqa: E402
|
||||
from superset.utils import json # noqa: E402
|
||||
|
||||
|
||||
def export_config_metadata() -> List[Dict[str, Any]]:
|
||||
"""Export configuration metadata as JSON."""
|
||||
config = SupersetConfig()
|
||||
|
||||
# Get all settings metadata
|
||||
settings_metadata = config.DATABASE_SETTINGS_SCHEMA
|
||||
|
||||
# Transform metadata for documentation
|
||||
docs_metadata = []
|
||||
|
||||
for key, schema in settings_metadata.items():
|
||||
# Skip readonly settings for user documentation
|
||||
if schema.get("readonly", False):
|
||||
continue
|
||||
|
||||
# Build environment variable name
|
||||
env_var = f"SUPERSET__{key}"
|
||||
|
||||
# Extract nested example if available
|
||||
nested_example = None
|
||||
if schema.get("type") == "object" and "example" in schema:
|
||||
nested_example = f"SUPERSET__{key}__example__nested_key=value"
|
||||
|
||||
# Format type information
|
||||
type_info = str(schema.get("type", "unknown"))
|
||||
if type_info == "integer":
|
||||
min_val = schema.get("minimum")
|
||||
max_val = schema.get("maximum")
|
||||
if min_val is not None or max_val is not None:
|
||||
min_str = str(min_val) if min_val is not None else "N/A"
|
||||
max_str = str(max_val) if max_val is not None else "N/A"
|
||||
type_info += f" ({min_str} - {max_str})"
|
||||
|
||||
doc_entry = {
|
||||
"key": key,
|
||||
"title": schema.get("title", key),
|
||||
"description": schema.get("description", ""),
|
||||
"type": type_info,
|
||||
"category": schema.get("category", "general"),
|
||||
"impact": schema.get("impact", "medium"),
|
||||
"requires_restart": schema.get("requires_restart", True),
|
||||
"default": schema.get("default"),
|
||||
"env_var": env_var,
|
||||
"nested_example": nested_example,
|
||||
"documentation_url": schema.get("documentation_url"),
|
||||
}
|
||||
|
||||
docs_metadata.append(doc_entry)
|
||||
|
||||
# Group by category
|
||||
categories: Dict[str, List[Dict[str, Any]]] = {}
|
||||
for entry in docs_metadata:
|
||||
category = str(entry["category"])
|
||||
if category not in categories:
|
||||
categories[category] = []
|
||||
categories[category].append(entry)
|
||||
|
||||
# Sort entries within each category
|
||||
for category in categories:
|
||||
categories[category].sort(key=lambda x: x["key"])
|
||||
|
||||
# Export as JSON
|
||||
output_dir = Path(__file__).parent.parent / "src" / "resources"
|
||||
output_dir.mkdir(exist_ok=True)
|
||||
|
||||
# Export all settings
|
||||
with open(output_dir / "config_metadata.json", "w") as f:
|
||||
f.write(
|
||||
json.dumps(
|
||||
{
|
||||
"all_settings": docs_metadata,
|
||||
"by_category": categories,
|
||||
"categories": list(categories.keys()),
|
||||
},
|
||||
indent=2,
|
||||
)
|
||||
)
|
||||
|
||||
output_file = output_dir / "config_metadata.json"
|
||||
print(f"Exported {len(docs_metadata)} configuration settings to {output_file}")
|
||||
return docs_metadata
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
export_config_metadata()
|
||||
40
docs/scripts/update_docs.sh
Executable file
40
docs/scripts/update_docs.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# Update documentation with latest configuration metadata
|
||||
# This script should be run before building the documentation
|
||||
|
||||
set -e
|
||||
|
||||
echo "Updating configuration metadata for documentation..."
|
||||
|
||||
# Navigate to the docs directory
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# Export configuration metadata
|
||||
echo "Exporting configuration metadata..."
|
||||
python scripts/export_config_metadata.py
|
||||
|
||||
echo "Configuration metadata updated successfully!"
|
||||
echo "The following files were updated:"
|
||||
echo "- src/resources/config_metadata.json"
|
||||
echo ""
|
||||
echo "To build the documentation with the latest metadata:"
|
||||
echo " npm install"
|
||||
echo " npm run build"
|
||||
Reference in New Issue
Block a user