### Build and Test Project with Act and Docker Source: https://github.com/ml-tooling/lazydocs/blob/main/README.md This command utilizes Act and Docker to build and test the project. It executes the 'build' job within a containerized environment, simplifying the development workflow. Docker and Act must be installed prior to running this command. ```bash act -b -j build ``` -------------------------------- ### Generate Documentation with Lazydocs Python API Source: https://github.com/ml-tooling/lazydocs/blob/main/README.md This snippet demonstrates how to use the Lazydocs Python API to generate documentation for specified modules. It takes a list of modules and an output path as arguments. Ensure Lazydocs is installed in your Python environment. ```python from lazydocs import generate_docs generate_docs(["my_module"], output_path="./docs") ``` -------------------------------- ### Output Documentation to Console Source: https://github.com/ml-tooling/lazydocs/blob/main/README.md Redirect the generated markdown output directly to the standard output stream instead of writing to files. ```bash lazydocs --output-path=stdout my_package ``` -------------------------------- ### Integrate Lazydocs with MkDocs Source: https://github.com/ml-tooling/lazydocs/blob/main/README.md Commands and configuration to generate documentation files for an MkDocs site and define the navigation structure using .pages files. ```bash lazydocs \ --output-path="./docs/api-docs" \ --overview-file="README.md" \ --src-base-url="https://github.com/example/my-project/blob/main/" \ my_package ``` ```yaml title: API Reference nav: - Overview: README.md - ... ``` -------------------------------- ### Initialize MarkdownGenerator Source: https://github.com/ml-tooling/lazydocs/blob/main/docs/lazydocs.generation.md Initializes the MarkdownGenerator instance with configuration for source paths, base URLs, and formatting options. ```python MarkdownGenerator( src_root_path=None, src_base_url=None, remove_package_prefix=False, url_line_prefix=None ) ``` -------------------------------- ### Generate API Docs with MkDocs Integration (Bash) Source: https://context7.com/ml-tooling/lazydocs/llms.txt This bash command demonstrates how to use lazydocs to generate API documentation and integrate it with MkDocs. It specifies output paths, an overview file, source code base URL, and enables table of contents generation. The command assumes 'my_package' is the Python package to document. ```bash lazydocs \ --output-path="./docs/api-docs" \ --overview-file="README.md" \ --src-base-url="https://github.com/myorg/myproject/blob/main/" \ --toc \ my_package ``` -------------------------------- ### Creating API Overviews with overview2md Source: https://context7.com/ml-tooling/lazydocs/llms.txt Generates an API overview document that links to all previously documented modules, classes, and functions. ```python from lazydocs import MarkdownGenerator import my_package.module_a generator = MarkdownGenerator() generator.module2md(my_package.module_a) # Generate overview overview = generator.overview2md() # Generate MDX overview mdx_overview = generator.overview2md(is_mdx=True) ``` -------------------------------- ### Generate Documentation via CLI Source: https://context7.com/ml-tooling/lazydocs/llms.txt The command-line interface allows for rapid generation of documentation from packages, modules, or classes. It supports various options like output paths, source linking, format selection (markdown/mdx), and module filtering. ```bash lazydocs path/to/your/package lazydocs my_package.module_name lazydocs my_package.AwesomeClass lazydocs --output-path="./docs/api-docs" --overview-file="README.md" --src-base-url="https://github.com/example/my-project/blob/main/" --remove-package-prefix --watermark --validate --toc my_package lazydocs --output-path=stdout my_package lazydocs --output-format=mdx --output-path="./docs" my_package lazydocs --ignored-modules internal --ignored-modules deprecated my_package ``` -------------------------------- ### Lazydocs CLI Usage Source: https://github.com/ml-tooling/lazydocs/blob/main/README.md General command-line interface syntax for invoking the lazydocs tool with various configuration options. ```bash lazydocs [OPTIONS] PATHS... ``` -------------------------------- ### Generate Documentation Overview and TOC Source: https://github.com/ml-tooling/lazydocs/blob/main/docs/lazydocs.generation.md Methods to generate high-level documentation summaries and tables of contents for modules and objects. ```python overview2md(is_mdx: bool = False) -> str toc2md(module: module = None, is_mdx: bool = False) -> str ``` -------------------------------- ### Programmatic API Documentation Generation (Python) Source: https://context7.com/ml-tooling/lazydocs/llms.txt This Python code shows how to use lazydocs programmatically to generate API documentation. It covers both a high-level function `generate_docs` for straightforward generation and a lower-level approach using `MarkdownGenerator` for more control over individual module and overview documentation. ```python from lazydocs import generate_docs, MarkdownGenerator from lazydocs.generation import to_md_file # Generate docs programmatically generate_docs( paths=["my_package"], output_path="./docs/api", overview_file="README.md", src_base_url="https://github.com/user/repo/blob/main/", remove_package_prefix=True, watermark=True, include_toc=True ) # Or with more control using MarkdownGenerator generator = MarkdownGenerator( src_base_url="https://github.com/user/repo/blob/main/" ) import my_package.core import my_package.utils # Generate and write individual module docs for module in [my_package.core, my_package.utils]: markdown = generator.module2md(module, include_toc=True) to_md_file(markdown, module.__name__, out_path="./docs/api") # Generate and write overview to_md_file(generator.overview2md(), "README", out_path="./docs/api") ``` -------------------------------- ### Generate Project Documentation with lazydocs Source: https://github.com/ml-tooling/lazydocs/blob/main/docs/lazydocs.generation.md The generate_docs function automates the creation of documentation for a list of source paths. It processes docstrings, handles module exclusions, and supports configuration for output paths and source URL linking. ```python from lazydocs.generation import generate_docs generate_docs( paths=["./src/my_package"], output_path="./docs", include_toc=True, validate=True ) ``` -------------------------------- ### Programmatic API Usage Source: https://github.com/ml-tooling/lazydocs/blob/main/README.md Integrate Lazydocs directly into Python scripts using the MarkdownGenerator class or the generate_docs helper function. ```python from lazydocs import MarkdownGenerator generator = MarkdownGenerator() # Select a module (e.g. my_module) to generate markdown documentation markdown_docs = generator.import2md(my_module) ``` ```python from lazydocs import generate_docs ``` -------------------------------- ### Validate Docstrings with Pydocstyle Source: https://github.com/ml-tooling/lazydocs/blob/main/README.md Use the validate flag to ensure all docstrings comply with Google-style formatting before generating documentation. ```bash lazydocs --validate my_package ``` -------------------------------- ### Writing Documentation to Files with to_md_file Source: https://context7.com/ml-tooling/lazydocs/llms.txt Utility function for saving generated Markdown strings to files with options for watermarks and formatting. ```python from lazydocs.generation import to_md_file # Write to file with watermark to_md_file( markdown_str="# Docs", filename="my_module", out_path="./docs", watermark=True, disable_markdownlint=True ) ``` -------------------------------- ### Documenting Python Classes with class2md Source: https://context7.com/ml-tooling/lazydocs/llms.txt Demonstrates how to generate Markdown documentation for standard classes, Enums, and dataclasses using the class2md method. ```python from lazydocs import MarkdownGenerator from dataclasses import dataclass from enum import Enum generator = MarkdownGenerator() # Document a regular class class DataProcessor: """A class for processing data.""" def __init__(self, config: dict): self.config = config markdown = generator.class2md(DataProcessor) # Document an Enum class class Status(Enum): PENDING = 1 enum_markdown = generator.class2md(Status) # Document a dataclass @dataclass class User: name: str dataclass_markdown = generator.class2md(User) ``` -------------------------------- ### Generate Documentation Programmatically Source: https://context7.com/ml-tooling/lazydocs/llms.txt The generate_docs function provides a high-level programmatic interface to generate documentation. It accepts a list of paths and various configuration parameters to customize the output, validation, and formatting. ```python from lazydocs import generate_docs generate_docs(["my_package"], output_path="./docs") generate_docs( paths=["my_package"], output_path="./docs/api", src_base_url="https://github.com/username/repo/blob/main/", overview_file="README.md", watermark=True ) generate_docs( paths=["my_package", "another_module.py"], output_path="./docs", validate=True, remove_package_prefix=True, ignored_modules=["my_package.internal", "my_package._private"] ) generate_docs( paths=["my_package"], output_path="./docs", output_format="mdx", include_toc=True, private_modules=True ) generate_docs( paths=["my_package.MyClass"], output_path="stdout" ) ``` -------------------------------- ### Generating Module Documentation with module2md Source: https://context7.com/ml-tooling/lazydocs/llms.txt Generates complete documentation for an entire Python module, supporting table of contents and MDX output formats. ```python from lazydocs import MarkdownGenerator import my_module generator = MarkdownGenerator(src_root_path="/project/src") # Generate module documentation markdown = generator.module2md(my_module, include_toc=True) # Generate MDX format mdx_markdown = generator.module2md(my_module, is_mdx=True, include_toc=True) ``` -------------------------------- ### Universal Documentation with import2md Source: https://context7.com/ml-tooling/lazydocs/llms.txt Automatically detects the type of Python object (module, class, or function) and generates the appropriate documentation. ```python from lazydocs import MarkdownGenerator import json generator = MarkdownGenerator() # Works with modules, classes, and functions module_docs = generator.import2md(json) from collections import OrderedDict class_docs = generator.import2md(OrderedDict) from os.path import join func_docs = generator.import2md(join) ``` -------------------------------- ### Generate Markdown from Python Objects Source: https://github.com/ml-tooling/lazydocs/blob/main/docs/lazydocs.generation.md A collection of methods to convert classes, functions, modules, and imports into markdown documentation. These methods support configurable heading depths and optional MDX/JSX formatting. ```python class2md(cls: Any, depth: int = 2, is_mdx: bool = False) -> str func2md(func: Callable, clsname: str = '', depth: int = 3, is_mdx: bool = False) -> str import2md(obj: Any, depth: int = 1, is_mdx: bool = False, include_toc: bool = False) -> str module2md(module: module, depth: int = 1, is_mdx: bool = False, include_toc: bool = False) -> str ``` -------------------------------- ### Write Markdown to File with lazydocs Source: https://github.com/ml-tooling/lazydocs/blob/main/docs/lazydocs.generation.md The to_md_file function writes a provided Markdown string to a specified file system path. It supports optional features like adding a timestamp watermark, disabling markdownlint, and enabling MDX support. ```python from lazydocs.generation import to_md_file to_md_file( markdown_str="# API Documentation\nContent here...", filename="api_docs", out_path="./docs", watermark=True, disable_markdownlint=True ) ``` -------------------------------- ### Generate Markdown with MarkdownGenerator Source: https://context7.com/ml-tooling/lazydocs/llms.txt The MarkdownGenerator class offers fine-grained control for generating documentation for specific Python objects. It provides methods like import2md, func2md, and class2md to convert modules, functions, and classes into markdown strings. ```python from lazydocs import MarkdownGenerator # Initialize generator generator = MarkdownGenerator( src_root_path="/path/to/project", src_base_url="https://github.com/user/repo/blob/main/", remove_package_prefix=True ) # Generate for module import my_module markdown = generator.import2md(my_module) # Generate for function def calculate_sum(a: int, b: int) -> int: """Calculate the sum of two numbers.""" return a + b func_md = generator.func2md(calculate_sum) # Generate for class method class MyClass: def process(self, data: str) -> str: return data.upper() method_md = generator.func2md(MyClass.process, clsname="MyClass", depth=4) ``` -------------------------------- ### Excluding Objects from Documentation Source: https://context7.com/ml-tooling/lazydocs/llms.txt Use the 'lazydocs: ignore' instruction within a docstring to exclude specific code elements from the generated documentation. ```python def internal_helper(): """Internal function. lazydocs: ignore """ pass ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.