--- id: cogapp version: "3.6.0" license: MIT license_treatment: permissive maintenance: active --- # cogapp — Cog: A content generator for executing Python snippets in source files. License: permissive · Maintenance: active · Downloads: 253.5K/mo ## What it is and what it does Cog is a content generator that finds Python code blocks marked in source files, executes them, and replaces the marked regions with their output. It's designed for static files—documentation, HTML, configuration, or any text format—where you want computed or templated content without a full build system. The tool reads the source, runs the embedded Python, and writes the result back in place. It has no external runtime dependencies and runs on Python 3.9 and later. The workflow is straightforward: mark a code block with special comments, run the tool on the file, and the output replaces the marked section. This is useful for keeping generated content (like tables, API docs, or configuration examples) in sync with the code that produces them, without requiring a separate templating language or build step. Use it for: - Keep API documentation examples in sync by embedding Python code that generates them. - Generate configuration file snippets or boilerplate from Python logic. - Maintain data tables or reference lists in markdown by computing them from live data. - Embed test output or validation results directly into README or guide files. - Generate HTML or XML fragments from Python without a full template engine. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Cog executes Python code snippets embedded in source files and replaces them with their output, enabling dynamic content generation in static files. Yes. Cog is lightweight, actively maintained, has no dependencies, and solves a specific problem well: keeping computed content in sync with its source code. Install it if you need to embed executable Python in static files and regenerate their output on demand. The MIT license and broad Python version support make it low-risk. ## Install pip install cogapp uv add cogapp poetry add cogapp ## Installing cogapp Before you install: Low friction: pure Python wheel with no runtime dependencies. Active maintenance with recent commits and stable production status across Python 3.9–3.14. License in practice: MIT license permits commercial and private use with minimal restrictions; attribution required. Quickstart: pip install cogapp In a source file, mark a code block with special delimiters, then run cogapp to execute the embedded code and replace the marked section with its output. Requires Python 3.9 or later. Verify before relying: - Whether the package handles complex nested code generation or only simple linear snippets. - Performance characteristics on large files or many embedded snippets. - Integration patterns with common static site generators (Hugo, Jekyll, Sphinx). - Exact syntax and delimiter format for marking code blocks in different file types. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 253.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags code generation from python snippets, dynamic content in static files, embedded python execution, template-like code generation, source file content generation, python snippet processor, static file templating, code-generation, static-site-tools, documentation [View on SkillFed](https://skillfed.io/packages/cogapp) · [View on PyPI](https://pypi.org/project/cogapp/)