ledoc-ui

0.1.0 · active · verified Thu Apr 16

ledoc-ui is a Python package that bundles static files for the 'livedoc' user interface. It acts as a convenient way to distribute the HTML, CSS, and JavaScript assets of the 'livedoc' UI, which is designed to display API documentation (often generated by frameworks like Spring). The package itself does not contain Python logic for UI generation or interaction but rather provides the front-end resources for a web application to serve. The current version is 0.1.0, and its release cadence appears irregular based on its minimal activity.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to serve the static web assets provided by `ledoc-ui` using the Flask web framework. The key is to locate the `static` directory within the installed `ledoc_ui` package and configure your web server to serve files from there. This example provides two routes: one for the main `index.html` and a catch-all for other static assets. Users would then navigate to the Flask application's root URL to access the `livedoc` UI in their browser.

import os
from flask import Flask, send_from_directory
import pkg_resources

app = Flask(__name__)

# Get the path to the static files bundled with ledoc-ui
try:
    LEDOCO_UI_STATIC_PATH = pkg_resources.resource_filename('ledoc_ui', 'static')
except ImportError:
    # Fallback if pkg_resources isn't ideal or if the structure changes
    # This assumes 'ledoc_ui' is installed in site-packages and 'static' is a direct subdir.
    # A more robust solution might involve __file__ and os.path.dirname logic if pkg_resources fails.
    print("Warning: pkg_resources failed. Attempting fallback for ledoc-ui static path.")
    LEDOCO_UI_STATIC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'env', 'lib', 'pythonX.Y', 'site-packages', 'ledoc_ui', 'static')
    # Replace 'pythonX.Y' with your actual Python version or adjust path as needed

@app.route('/')
def index():
    # Serve the main index.html from ledoc-ui's static folder
    return send_from_directory(LEDOCO_UI_STATIC_PATH, 'index.html')

@app.route('/<path:filename>')
def serve_static(filename):
    # Serve other static files (CSS, JS, images) from ledoc-ui's static folder
    return send_from_directory(LEDOCO_UI_STATIC_PATH, filename)

if __name__ == '__main__':
    print(f"Serving ledoc-ui static files from: {LEDOCO_UI_STATIC_PATH}")
    app.run(debug=True)

view raw JSON →