### Bash Commands for Dependency Installation and Execution Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Provides shell commands for setting up the project. It shows how to install dependencies using `pip` or `uv`, run the main Python script, and illustrates the expected output directory structure after execution. ```bash # Install dependencies pip install html2text requests # Or using uv uv pip install html2text requests # Run the exporter python main.py # Expected output structure: # 51AES_Docs/ # └── WDPAPI/ # ├── 功能组件/ # │ ├── 工具.md # │ ├── 控件.md # │ └── 环境.md # ├── 场景初始/ # │ └── 初始场景.md # ├── 场景相机/ # │ ├── 相机通用行为.md # │ └── 相机模式_位置_限制设置.md # └── 实体覆盖物/ # ├── POI.md # ├── 3D文字.md # └── 路径.md ``` -------------------------------- ### Python HTML to Markdown Conversion Setup Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Initializes an HTML2Text converter with specific settings to control link, image, table handling, and line wrapping. This setup is crucial for preparing HTML content for Markdown conversion. ```python import html2text converter = html2text.HTML2Text() converter.ignore_links = False converter.ignore_images = False converter.ignore_tables = False converter.body_width = 0 converter.protect_links = True ``` -------------------------------- ### Add Path Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This JavaScript example shows how to define a 'Path' instance, which represents a line or route on the map. It includes a polyline defining the coordinates, pathStyle for visual appearance (like arrow type, color), visibility, entity name, custom ID, and custom data. ```javascript { "type": "Path", "polyline": { "coordinates": [ [121.50114770,31.23691142,93], [121.48007773,31.22050415,27], [121.47985493,31.24031196,45], [121.49030648,31.23537047,33] ] }, "pathStyle": { "type": "arrow", "width": 100, "color": "eaffc7ff", "passColor": "ff6d96ff" }, "bVisible": true, "entityName": "myName6", "customId": "myId6", "customData": { "data": "Path" } } ``` -------------------------------- ### Add Text3D Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This code example shows how to add a 'Text3D' instance to the map. It configures the text content, color, outline, and other styling properties within text3DStyle, along with location, rotation, scale, visibility, and entity identification. This is for displaying 3D text labels. ```javascript { "type": "Text3D", "location": [121.46376561,31.22870602,76], "rotator": { "pitch": 0, "yaw": 30, "roll": 0 }, "scale3d": [1000, 100, 100], "text3DStyle": { "text": "3D文字", "color": "10ff1bff", "type": "plain", "outline": 0.4, "portrait": false, "space": 0.1 }, "bVisible": true, "entityName": "myName4", "customId": "myId3", "customData": { "data": "Text3D" } } ``` -------------------------------- ### Python Main Execution Function Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt The main function orchestrates the documentation export process. It fetches the outline, checks for its availability, and then initiates the recursive processing of nodes starting from the root. Includes error handling for fetching the outline and provides feedback on the export process. ```python import sys import os OUTPUT_DIR = "./51AES_Docs" def main(): print("=== 51AES Documentation Exporter ===") outline_data = fetch_outline() if not outline_data: print("❌ Terminating: cannot fetch outline") sys.exit(1) print(f"📂 Output directory: {os.path.abspath(OUTPUT_DIR)}\n") for root_node in outline_data: process_node(root_node, OUTPUT_DIR) print("\n✅ Export complete!") if __name__ == "__main__": main() ``` -------------------------------- ### Fetch API Documentation Outline using Python Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Retrieves the hierarchical structure of the documentation tree from the WDPAPI server using a GET request. It expects a JSON response with a 'code' and 'data' field, where 'data' contains the nested documentation nodes. Includes basic error handling for the request. ```python import requests OUTLINE_URL = "https://wdpapi-admin.51aes.com/api/outline/123" HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" } # Fetch the documentation outline resp = requests.get(OUTLINE_URL, headers=HEADERS, timeout=10) resp.raise_for_status() data = resp.json() if data.get("code") == 200 and data.get("data"): outline_data = data["data"] # outline_data contains nested structure with nodes like: # [{"id": 123, "name": "API Category", "children": [...]}] print(f"Retrieved {len(outline_data)} root nodes") else: print(f"Failed to fetch outline: {data}") ``` -------------------------------- ### Create Scene Instances Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md Creates various scene instances such as heatmaps, ranges, and lights based on the provided JSON data and coordinate settings. ```APIDOC ## Create Scene Instances ### Description Creates various scene instances such as heatmaps, ranges, and lights based on the provided JSON data and coordinate settings. ### Method POST ### Endpoint /scene/creates ### Parameters #### Request Body - **jsondata** (object) - Required - JSON object containing scene element configurations. - **options** (object) - Optional - Configuration for coordinate type and height. - **calculateCoordZ** (object) - Optional - Specifies coordinate type and height. - **coordZRef** (string) - Required - Reference for coordinate Z ('surface', 'ground', 'altitude'). - **coordZOffset** (number) - Optional - Offset for altitude in meters. ### Request Example ```javascript const jsondata = [ // ... (JSON data for scene elements like heatmaps, ranges, lights) ... ]; const res = await App.Scene.Creates(jsondata, { "calculateCoordZ": { "coordZRef": "surface", "coordZOffset": 200 } }); console.log(res); ``` ### Response #### Success Response (200) - **result** (any) - The result of the creation operation. ``` -------------------------------- ### Light Configuration (JSON) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This JSON object configures a light source in the scene, detailing its location, rotation, scale, and light style properties such as intensity, color, angle, attenuation, and shadow/haze effects. It also includes visibility and custom data. ```json { "type": "Light", "location": [121.49189794,31.24282414,0], "rotator": { "pitch": 0, "yaw": 0, "roll": 0 }, "scale3d": [100, 100, 100], "lightStyle": { "intensity": 40, "color": "ff00ff", "angle": 50, "attenuation": 200, "shadows": true, "haze": true, "haze_Intensity": 90 }, "bVisible": true, "entityName": "myName14", "customId": "myId14", "customData": { "data": "CircleRange" } } ``` -------------------------------- ### Add Window Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This snippet demonstrates how to add a 'Window' type instance. It includes properties like type, location, windowStyle (with URL, size, offset), visibility, entityName, customId, and customData. This is useful for displaying interactive windows on the map. ```javascript { "type": "Window", "location": [121.46426478,31.22406702,47], "windowStyle": { "url": "http://wdpapi.51aes.com/doc-static/images/static/echarts.html", "size": [500, 350], "offset": [0, 0] }, "bVisible": true, "entityName": "myName1", "customId": "myId1", "customData": { "data": "Window" } } ``` -------------------------------- ### Set Instance Scale3D (Uniform) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md Sets the uniform scale for multiple 3D scene objects. ```APIDOC ## Set Instance Scale3D (Uniform) ### Description Sets the uniform scale for multiple 3D scene objects. ### Method POST ### Endpoint /scene/setScale3D ### Parameters #### Request Body - **obj** (array) - Required - An array of 3D scene objects (e.g., Particle, Text3D, Light, Model). - **scale** (object) - Required - The uniform scaling factors. - **x** (number) - Required - Scaling factor for the X-axis. - **y** (number) - Required - Scaling factor for the Y-axis. - **z** (number) - Required - Scaling factor for the Z-axis. ### Request Example ```javascript const obj = [particleObj, text3dObj]; const res = await App.Scene.SetScale3D(obj, { "x": 400, "y": 400, "z": 400 }); console.log(res); ``` ### Response #### Success Response (200) - **result** (any) - The result of the scale operation. ``` -------------------------------- ### Batch Add Scene Instances Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md Adds multiple scene instances to the scene in a batch operation with optional coordinate settings. ```APIDOC ## Batch Add Scene Instances ### Description Adds multiple scene instances to the scene in a batch operation with optional coordinate settings. ### Method POST ### Endpoint /scene/add ### Parameters #### Request Body - **objs** (array) - Required - An array of scene objects to add. - **options** (object) - Optional - Configuration for coordinate type and height. - **calculateCoordZ** (object) - Optional - Specifies coordinate type and height. - **coordZRef** (string) - Required - Reference for coordinate Z ('surface', 'ground', 'altitude'). - **coordZOffset** (number) - Optional - Offset for altitude in meters. ### Request Example ```javascript const objs = [poiObject, pathObject, particleObject]; const res = await App.Scene.Add(objs, { "calculateCoordZ": { "coordZRef": "surface", "coordZOffset": 50 } }); console.log(res); ``` ### Response #### Success Response (200) - **result** (any) - The result of the add operation. ``` -------------------------------- ### Batch Add Scene Objects with Coordinate Z Calculation (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This snippet shows how to add multiple scene objects in a batch using `App.Scene.Add`. It also includes the option to specify coordinate Z calculation parameters, similar to the `Creates` method. ```javascript const objs = [poiObject, pathObject, particleObject]; const res = await App.Scene.Add(objs, { calculateCoordZ: { coordZRef: "surface", //surface:表面; ground:地面; altitude:海拔 coordZOffset: 50 //高度(单位:米) } }); console.log(res); ``` -------------------------------- ### Batch Set Instance Scale (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This snippet demonstrates how to set a uniform scale for multiple scene objects using `App.Scene.SetScale3D`. It takes an array of objects and the desired scale factors for the x, y, and z axes. ```javascript const obj = [ // 单体3D实体对象(场景特效 Particle, 3D文字 Text3D, 粒子特效 Effects, 灯光 Light, 模型) particleObj, text3dObj ]; const res = await App.Scene.SetScale3D(obj, { x: 400, //缩放比例 y: 400, z: 400 }); console.log(res); ``` -------------------------------- ### TOML Project Configuration for WDPAPI Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Defines the project metadata and dependencies for the WDPAPI documentation exporter using TOML format. Specifies project name, version, description, Python version requirement, and lists external libraries like `html2text` and `requests` with version constraints. ```toml # pyproject.toml [project] name = "wdpapiwiki" version = "0.1.0" description = "51AES WDPAPI documentation exporter" readme = "README.md" requires-python = ">=3.13" dependencies = [ "html2text>=2025.4.15", "requests>=2.32.5", ] ``` -------------------------------- ### Create Scene Objects with Coordinate Z Calculation (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This snippet demonstrates how to create scene objects using `App.Scene.Creates` with options for coordinate Z calculation. It specifies the reference for the Z coordinate (surface, ground, or altitude) and an optional offset. ```javascript const jsondata = { "type": "cube", "brushDiameter": 1000, "mappingValueRange": [1, 100], "columnarWidth": 20, "mappingHeightRange": [0, 500], "enableGap": false, "gradientSetting": [ "f7ffbfff", "ff0083ff", "8991ffff", "a0a7feff", "ff2131ff" ] }; const res = await App.Scene.Creates(jsondata, { // 坐标类型 "calculateCoordZ": { // [可选];坐标类型及坐标高度; 最高优先级 "coordZRef":"surface",// surface: 表面; ground: 地面; altitude: 海拔, "coordZOffset": 200 // 海拔高度(单位:米) } }); console.log(res); ``` -------------------------------- ### Add HeatMap Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This snippet shows how to create a 'HeatMap' instance. It configures heatmapStyle (type, brush diameter, value range, gradient colors) and provides points with their respective values. Heatmaps visualize data density across an area. ```javascript { "type": "HeatMap", "heatMapStyle": { "type": "fit", "brushDiameter": 2000, "mappingValueRange": [1, 100], "gradientSetting": [ "b4ff25ff", "a174ffff", "2e15feff", "d0ff30ff", "b3ffa4ff" ] }, "bVisible": true, "entityName": "myName9", "customId": "myId9", "customData": { "data": "HeatMap" }, "points": { "features": [ { "point": [121.48783892,31.22955413,91], "value": 87 }, { "point": [121.49360144,31.23134998,41], "value": 80 }, { "point": [121.46524329,31.24312496,77], "value": 95 }, { "point": [121.48712254,31.24286490,34], "value": 70 }, { "point": [121.47944776,31.24252262,86], "value": 65 } ] } } ``` -------------------------------- ### Fetch and Convert API Documentation Content to Markdown using Python Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Fetches HTML content for a specific documentation page by its ID and converts it to Markdown format using the `html2text` library. Includes rate limiting with a small delay between requests and robust error handling for network issues and JSON parsing. The converter is configured to preserve code blocks and tables. ```python import requests import html2text import time CONTENT_BASE_URL = "https://wdpapi-admin.51aes.com/api/content/" REQUEST_DELAY = 0.2 # Initialize HTML to Markdown converter converter = html2text.HTML2Text() converter.ignore_links = False converter.ignore_images = False converter.ignore_tables = False converter.body_width = 0 # Preserve code blocks and tables converter.protect_links = True def fetch_content_and_convert(content_id, node_name): """Fetch content by ID and convert HTML to Markdown""" if not content_id or content_id == 0: return None url = f"{CONTENT_BASE_URL}{content_id}" try: time.sleep(REQUEST_DELAY) # Rate limiting resp = requests.get(url, headers=HEADERS, timeout=10) if resp.status_code != 200: print(f"Request failed ({resp.status_code}): {node_name}") return None res_json = resp.json() if res_json.get("code") == 200: data_list = res_json.get("data") if isinstance(data_list, list) and len(data_list) > 0: html_content = data_list[0] if html_content: # Convert HTML to Markdown markdown_content = converter.handle(html_content) return markdown_content return None except Exception as e: print(f"Exception fetching content: {e}") return None # Example usage content_id = 456 markdown = fetch_content_and_convert(content_id, "API Documentation") if markdown: print(f"Successfully converted {len(markdown)} characters to Markdown") ``` -------------------------------- ### SpaceHeatMap Configuration (JSON) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This JSON object defines a SpaceHeatMap, including its style parameters like brush diameter, value range mapping, and gradient colors. It also contains visibility settings, entity name, custom ID, and point data. ```json { "type": "SpaceHeatMap", "spaceHeatMapStyle": { "brushDiameter": 100, "mappingValueRange": [1, 100], "gradientSetting": [ "0000ff", "ff5500", "00ff00", "ffff00", "00ffff" ] }, "bVisible": true, "entityName": "myName12", "customId": "myId12", "customData": { "data": "SpaceHeatMap" }, "points": { "features": [ { "point": [121.48641573,31.23901035,87], "value": 87 }, { "point": [121.46117788,31.22258222,89], "value": 80 }, { "point": [121.47008568,31.22681936,13], "value": 95 }, { "point": [121.49895380,31.22317413,65], "value": 70 }, { "point": [121.47750177,31.22547035,94], "value": 65 } ] } } ``` -------------------------------- ### Add Parabola Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This snippet defines a 'Parabola' instance, often used for migration or flow visualization. It includes polyline coordinates, parabolaStyle (like top height, scale, type, color), visibility, entity name, custom ID, and custom data. ```javascript { "type": "Parabola", "polyline": { "coordinates": [ [121.47607446,31.24372538,84], [121.48749492,31.23361823,8] ] }, "parabolaStyle": { "topHeight": 800, "topScale": 1, "type": "scanline", "width": 20, "color": "b1ff8bff", "gather": true }, "bVisible": true, "entityName": "myName7", "customId": "myId7", "customData": { "data": "Parabola" } } ``` -------------------------------- ### Python Fetch Outline Function Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Fetches the documentation outline from a predefined URL. It handles potential request errors and JSON parsing issues, returning the outline data if successful or None otherwise. Includes specific checks for a successful API response code and data presence. ```python import requests OUTLINE_URL = "your_outline_url" HEADERS = {"User-Agent": "YourUserAgent"} def fetch_outline(): print(f"Fetching outline from: {OUTLINE_URL}") try: resp = requests.get(OUTLINE_URL, headers=HEADERS, timeout=10) resp.raise_for_status() data = resp.json() if data.get("code") == 200 and data.get("data"): print("✅ Outline retrieved successfully") return data["data"] else: print(f"❌ Outline fetch failed: {data}") return None except Exception as e: print(f"❌ Exception fetching outline: {e}") return None ``` -------------------------------- ### Add Poi Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This code defines a 'Poi' (Point of Interest) instance. It specifies location, poiStyle (including marker images, label styles), visibility, entityName, customId, and customData. POIs are used to mark specific locations on the map. ```javascript { "type": "Poi", "location": [121.46491415,31.21866105,87], "poiStyle": { "markerNormalUrl": "http://wdpapi.51aes.com/doc-static/images/static/markerNormal.png", "markerActivateUrl": "http://wdpapi.com/doc-static/images/static/markerActive.png", "markerSize": [100, 228], "labelBgImageUrl": "http://wdpapi.51aes.com/doc-static/images/static/LabelBg.png", "labelBgSize": [200, 50], "labelBgOffset": [50, 200], "labelContent": [" 文本内容A", "ff0000ff", "24"] }, "bVisible": true, "entityName": "myName2", "customId": "myId2", "customData": { "data": "Poi" } } ``` -------------------------------- ### Fetch Documentation Outline Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Retrieves the complete hierarchical structure of the documentation tree from the API server. ```APIDOC ## GET /api/outline/{id} ### Description Retrieves the complete hierarchical structure of the documentation tree from the API server. ### Method GET ### Endpoint `https://wdpapi-admin.51aes.com/api/outline/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the outline to fetch. #### Query Parameters None #### Request Body None ### Request Example ```python import requests OUTLINE_URL = "https://wdpapi-admin.51aes.com/api/outline/123" HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" } resp = requests.get(OUTLINE_URL, headers=HEADERS, timeout=10) resp.raise_for_status() data = resp.json() ``` ### Response #### Success Response (200) - **code** (integer) - The status code of the response. - **data** (array) - An array of documentation nodes, where each node can contain nested children. - **id** (integer) - The ID of the node. - **name** (string) - The name of the node. - **children** (array) - An array of child nodes. #### Response Example ```json { "code": 200, "data": [ { "id": 123, "name": "API Category", "children": [ { "id": 456, "name": "API Documentation", "children": [] } ] } ] } ``` ``` -------------------------------- ### Add Viewshed Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This snippet demonstrates the configuration of a 'Viewshed' instance. It includes properties such as location, rotator, viewshedStyle (field of view, radius, colors), visibility, entity name, and custom ID. Viewsheds are used to visualize the area visible from a specific point. ```javascript { "type": "Viewshed", "location": [121.47315875,31.24472542,27], "rotator": { "pitch": 0, "yaw": 30, "roll": 0 }, "viewshedStyle": { "fieldOfView": 70, "radius": 600, "outline": true, "hiddenColor": "ff136dff", "visibleColor": "feaecfff" }, "bVisible": true, "entityName": "myName5", "customId": "myId5", "customData": { "data": "Viewshed" } } ``` -------------------------------- ### RoadHeatMap Configuration (JSON) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This JSON object defines a RoadHeatMap, specifying its style properties such as width, value range mapping, and gradient colors. It also includes visibility, entity name, custom ID, and custom data. ```json { "type": "RoadHeatMap", "roadHeatMapStyle": { "width": 50, "mappingValueRange": [1, 100], "gradientSetting": [ "ffee1aff", "ffb540ff", "f4ff4bff", "d961feff", "b456ffff" ], "type": "plane", "filter": [] }, "bVisible": true, "entityName": "myName11", "customId": "myId11", "customData": { "data": "RoadHeatMap" }, "points": { "features": [ { "point": [121.47799331,31.23097751,83], "value": 87 }, { "point": [121.49095564,31.22740179,57], "value": 80 }, { "point": [121.46961736,31.24484216,93], "value": 95 }, { "point": [121.49208500,31.25120664,52], "value": 70 }, { "point": [121.48651742,31.22413720,30], "value": 65 } ] } } ``` -------------------------------- ### Fetch and Convert Documentation Content Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Retrieves HTML content for a specific documentation page and converts it to Markdown format. ```APIDOC ## GET /api/content/{id} ### Description Retrieves HTML content for a specific documentation page by its ID and converts it to Markdown format. ### Method GET ### Endpoint `https://wdpapi-admin.51aes.com/api/content/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the content to fetch. #### Query Parameters None #### Request Body None ### Request Example ```python import requests import html2text import time CONTENT_BASE_URL = "https://wdpapi-admin.51aes.com/api/content/" REQUEST_DELAY = 0.2 HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" } converter = html2text.HTML2Text() converter.body_width = 0 def fetch_content_and_convert(content_id, node_name): if not content_id or content_id == 0: return None url = f"{CONTENT_BASE_URL}{content_id}" try: time.sleep(REQUEST_DELAY) resp = requests.get(url, headers=HEADERS, timeout=10) if resp.status_code != 200: print(f"Request failed ({resp.status_code}): {node_name}") return None res_json = resp.json() if res_json.get("code") == 200: data_list = res_json.get("data") if isinstance(data_list, list) and len(data_list) > 0: html_content = data_list[0] if html_content: markdown_content = converter.handle(html_content) return markdown_content return None except Exception as e: print(f"Exception fetching content: {e}") return None content_id = 456 markdown = fetch_content_and_convert(content_id, "API Documentation") ``` ### Response #### Success Response (200) - **code** (integer) - The status code of the response. - **data** (array) - An array containing the HTML content of the documentation page. - **html_content** (string) - The HTML content of the documentation page. #### Response Example ```json { "code": 200, "data": [ "
This is the documentation content.
" ] } ``` ``` -------------------------------- ### Complete API Documentation Export Script (Python) Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt This Python script provides a complete solution for exporting all documentation from a given API to local Markdown files. It utilizes libraries like 'requests' for API calls and 'html2text' for content conversion. The script configures API endpoints, output directory, request delays, and headers for proper operation. ```python #!/usr/bin/env python3 import os import sys import requests import html2text import re import time # Configuration OUTLINE_URL = "https://wdpapi-admin.51aes.com/api/outline/123" CONTENT_BASE_URL = "https://wdpapi-admin.51aes.com/api/content/" OUTPUT_DIR = "51AES_Docs" REQUEST_DELAY = 0.2 HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" } # Placeholder for fetch_content_and_convert, typically would involve API calls def fetch_content_and_convert(node_id, node_name): try: response = requests.get(f"{CONTENT_BASE_URL}{node_id}", headers=HEADERS) response.raise_for_status() # Raise an exception for bad status codes html_content = response.text # Convert HTML to Markdown h = html2text.HTML2Text() h.ignore_links = True h.ignore_images = True md_content = h.handle(html_content) # Add a small delay to avoid overwhelming the server time.sleep(REQUEST_DELAY) return md_content except requests.exceptions.RequestException as e: print(f"Error fetching content for ID {node_id}: {e}") return None except Exception as e: print(f"An unexpected error occurred during content fetch/conversion for ID {node_id}: {e}") return None # The rest of the script (sanitize_filename, process_node, example usage) would follow here, # ensuring that OUTPUT_DIR is created if it doesn't exist. if not os.path.exists(OUTPUT_DIR): try: os.makedirs(OUTPUT_DIR) print(f"Created root output directory: {OUTPUT_DIR}") except OSError as e: print(f"Failed to create root output directory: {OUTPUT_DIR}, error: {e}") sys.exit(1) # Exit if the root directory cannot be created # --- Include the process_node and sanitize_filename functions from the previous snippet --- def sanitize_filename(name): """Clean illegal characters from filenames""" return re.sub(r'[\\/*?Ion"<>|]', "_", str(name)).strip() def process_node(node, parent_path): """Recursively traverse nodes, create folders and save files""" node_id = node.get("id") raw_name = node.get("name", "Untitled") node_name = sanitize_filename(raw_name) children = node.get("children", []) current_path = os.path.join(parent_path, node_name) if not os.path.exists(current_path): try: os.makedirs(current_path) print(f"Created directory: {current_path}") except OSError as e: print(f"Failed to create directory: {current_path}, error: {e}") return if node_id and node_id != 0: print(f"Processing: [{node_name}] (ID: {node_id})") md_content = fetch_content_and_convert(node_id, node_name) if md_content: file_path = os.path.join(current_path, f"{node_name}.md") try: with open(file_path, "w", encoding="utf-8") as f: f.write(f"# {raw_name}\n\n") f.write(md_content) print(f" ✓ Saved: {file_path}") except IOError as e: print(f" ✗ File write failed: {e}") for child in children: process_node(child, current_path) # --- Main execution logic --- def fetch_outline(url): """Fetches the documentation outline from the API.""" try: response = requests.get(url, headers=HEADERS) response.raise_for_status() # Add a small delay after fetching the outline as well time.sleep(REQUEST_DELAY) return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching outline from {url}: {e}") return None except ValueError: # includes JSONDecodeError print(f"Error decoding JSON response from {url}") return None if __name__ == "__main__": print("Starting documentation export...") outline_data = fetch_outline(OUTLINE_URL) if outline_data: # Assuming outline_data is a list of root nodes, similar to the example if isinstance(outline_data, list): for root_node in outline_data: process_node(root_node, OUTPUT_DIR) elif isinstance(outline_data, dict): # Handle case where outline is a single root object process_node(outline_data, OUTPUT_DIR) else: print("Error: Unexpected outline data format.") sys.exit(1) else: print("Failed to retrieve documentation outline. Exiting.") sys.exit(1) print("✅ Documentation export complete!") ``` -------------------------------- ### Process Documentation Tree Recursively (Python) Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt This Python script recursively processes a documentation tree. It sanitizes node names to create valid directory and file names, creates directories for each node, and saves content as Markdown files. Dependencies include the 'os' and 're' modules. It takes a hierarchical node structure as input and outputs a directory structure with Markdown files. ```python import os import re OUTPUT_DIR = "51AES_Docs" def sanitize_filename(name): """Clean illegal characters from filenames""" return re.sub(r'[\\/*?Ion"<>|]', "_", str(name)).strip() def process_node(node, parent_path): """Recursively traverse nodes, create folders and save files""" node_id = node.get("id") raw_name = node.get("name", "Untitled") node_name = sanitize_filename(raw_name) children = node.get("children", []) # Create directory for this node current_path = os.path.join(parent_path, node_name) if not os.path.exists(current_path): try: os.makedirs(current_path) print(f"Created directory: {current_path}") except OSError as e: print(f"Failed to create directory: {current_path}, error: {e}") return # Fetch and save content if node has valid ID if node_id and node_id != 0: print(f"Processing: [{node_name}] (ID: {node_id})") md_content = fetch_content_and_convert(node_id, node_name) # Assuming fetch_content_and_convert is defined elsewhere if md_content: file_path = os.path.join(current_path, f"{node_name}.md") try: with open(file_path, "w", encoding="utf-8") as f: f.write(f"# {raw_name}\n\n") f.write(md_content) print(f" ✓ Saved: {file_path}") except IOError as e: print(f" ✗ File write failed: {e}") # Recursively process child nodes for child in children: process_node(child, current_path) # Example usage - process entire documentation tree outline_data = [ { "id": 1, "name": "WDPAPI", "children": [ {"id": 2, "name": "Scene Initialization", "children": []}, {"id": 3, "name": "Camera Control", "children": []} ] } ] for root_node in outline_data: process_node(root_node, OUTPUT_DIR) print("✅ Documentation export complete!") ``` -------------------------------- ### Range (CircleRange) Configuration (JSON) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This JSON object defines a circular range area, specifying its center coordinates, radius, and styling properties like shape, type, fill area, height, stroke weight, and color. It also includes visibility and custom data. ```json { "type": "Range", "circlePolygon2D": { "center": [121.49986350,31.24269398,49], "radius": 300 }, "rangeStyle": { "shape": "circle", "type": "grid", "fillAreaType": "radar", "height": 150, "strokeWeight": 10, "color": "2948feff" }, "bVisible": true, "entityName": "myName13", "customId": "myId13", "customData": { "data": "CircleRange" } } ``` -------------------------------- ### Python Fetch and Convert Content Function Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Fetches HTML content for a given content ID, converts it to Markdown using the initialized converter, and returns the Markdown string. It includes error handling for network requests and response validation. A delay is introduced between requests to avoid overwhelming the server. ```python import requests import time CONTENT_BASE_URL = "your_content_base_url" HEADERS = {"User-Agent": "YourUserAgent"} REQUEST_DELAY = 1 # seconds def fetch_content_and_convert(content_id, node_name): if not content_id or content_id == 0: return None url = f"{CONTENT_BASE_URL}{content_id}" try: time.sleep(REQUEST_DELAY) resp = requests.get(url, headers=HEADERS, timeout=10) if resp.status_code != 200: print(f" [!] Request failed ({resp.status_code}): {node_name}") return None res_json = resp.json() if res_json.get("code") == 200: data_list = res_json.get("data") if isinstance(data_list, list) and len(data_list) > 0: html_content = data_list[0] if html_content: return converter.handle(html_content) return None except Exception as e: print(f" [!] Exception: {e}") return None ``` -------------------------------- ### Add Particle Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This JavaScript snippet illustrates the creation of a 'Particle' effect instance. It includes properties for location, rotation, visibility, scale, particle type, entity name, custom ID, and custom data. Particle effects can be used for visual enhancements like moving vehicles. ```javascript { "type": "Particle", "location": [121.49172858,31.22476437,67], "rotator": { "pitch": 0, "yaw": 30, "roll": 0 }, "bVisible": true, "scale3d": [50, 50, 50], "particleType": "vehicle_taxi", "entityName": "myName3", "customId": "myId3", "customData": { "data": "Particle" } } ``` -------------------------------- ### Add Range Instance (JavaScript) Source: https://github.com/radial-hks/wdpapiwiki/blob/main/51AES_Docs/WDPAPI/实体_单体通用行为/实体[批量]行为.md This code defines a 'Range' instance, which represents a 2D area or polygon on the map. It uses polygon2D coordinates and rangeStyle for defining the visual properties like fill type, height, stroke weight, and color. It also includes standard entity properties. ```javascript { "type": "Range", "polygon2D": { "coordinates": [ [ [121.47122131,31.24264779], [121.48769236,31.23035225], [121.50016626,31.22821735] ] ] }, "rangeStyle": { "type": "loop_line", "fillAreaType": "block", "height": 200, "strokeWeight": 10, "color": "6fff46ff" }, "bVisible": true, "entityName": "myName8", "customId": "myId8", "customData": { "data": "Range" } } ``` -------------------------------- ### Python Recursive Node Processing Function Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Recursively processes documentation nodes, creating directories and Markdown files. It sanitizes node names, fetches content if available, and writes it to a file. It then iterates through child nodes to continue the process. ```python import os OUTPUT_DIR = "./51AES_Docs" def process_node(node, parent_path): node_id = node.get("id") raw_name = node.get("name", "Untitled") node_name = sanitize_filename(raw_name) children = node.get("children", []) current_path = os.path.join(parent_path, node_name) if not os.path.exists(current_path): try: os.makedirs(current_path) except OSError as e: print(f"❌ Failed to create: {current_path}, error: {e}") return if node_id and node_id != 0: print(f"-> Processing: [{node_name}] (ID: {node_id})") md_content = fetch_content_and_convert(node_id, node_name) if md_content: file_path = os.path.join(current_path, f"{node_name}.md") try: with open(file_path, "w", encoding="utf-8") as f: f.write(f"# {raw_name}\n\n") f.write(md_content) except IOError as e: print(f" [!] Write failed: {e}") for child in children: process_node(child, current_path) ``` -------------------------------- ### Python Filename Sanitization Function Source: https://context7.com/radial-hks/wdpapiwiki/llms.txt Defines a function to sanitize filenames by removing characters that are invalid in most file systems. It replaces these characters with underscores and trims whitespace. This ensures compatibility across different operating systems. ```python import re def sanitize_filename(name): return re.sub(r'[\\/*?:'"<>|]', "_", str(name)).strip() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.