- Fixed import sorting in cli.py, __main__.py, detectors/__init__.py, base.py, python.py, rust.py, openapi.py, models/__init__.py - Removed unused imports (sys, asyncio, Observer, Text, Parameter, ParameterIn, HTTPMethod, DocConfig, List, Optional) - Removed trailing whitespace from blank lines - Split lines exceeding 100 characters - Added missing __init__ docstrings in generators and static/templates packages
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
"""HTML documentation generator."""
|
{"""HTML documentation generator."""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||||
from docgen.models import DocConfig, Endpoint
|
|
||||||
from docgen.generators import BaseGenerator
|
from docgen.generators import BaseGenerator
|
||||||
|
from docgen.models import DocConfig, Endpoint
|
||||||
|
|
||||||
|
|
||||||
def slugify(text: str) -> str:
|
def slugify(text: str) -> str:
|
||||||
@@ -16,6 +18,7 @@ class HTMLGenerator(BaseGenerator):
|
|||||||
"""Generator for Stripe-like interactive HTML documentation."""
|
"""Generator for Stripe-like interactive HTML documentation."""
|
||||||
|
|
||||||
def __init__(self, config: DocConfig = None):
|
def __init__(self, config: DocConfig = None):
|
||||||
|
"""Initialize the HTML generator."""
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
template_dir = Path(__file__).parent.parent / "templates"
|
template_dir = Path(__file__).parent.parent / "templates"
|
||||||
self.env = Environment(
|
self.env = Environment(
|
||||||
@@ -58,7 +61,7 @@ class HTMLGenerator(BaseGenerator):
|
|||||||
else:
|
else:
|
||||||
parts = endpoint.path.strip("/").split("/")
|
parts = endpoint.path.strip("/").split("/")
|
||||||
tag = parts[0] if parts else "Other"
|
tag = parts[0] if parts else "Other"
|
||||||
|
|
||||||
if tag not in grouped:
|
if tag not in grouped:
|
||||||
grouped[tag] = []
|
grouped[tag] = []
|
||||||
grouped[tag].append(endpoint)
|
grouped[tag].append(endpoint)
|
||||||
@@ -69,7 +72,7 @@ class HTMLGenerator(BaseGenerator):
|
|||||||
static_dir = Path(__file__).parent.parent / "static"
|
static_dir = Path(__file__).parent.parent / "static"
|
||||||
output_static = output_dir / "static"
|
output_static = output_dir / "static"
|
||||||
output_static.mkdir(exist_ok=True)
|
output_static.mkdir(exist_ok=True)
|
||||||
|
|
||||||
for file in static_dir.iterdir():
|
for file in static_dir.iterdir():
|
||||||
if file.is_file():
|
if file.is_file():
|
||||||
(output_static / file.name).write_text(file.read_text())
|
(output_static / file.name).write_text(file.read_text())
|
||||||
|
|||||||
Reference in New Issue
Block a user