Skip to content

Commit 35c135f

Browse files
committed
init
0 parents  commit 35c135f

File tree

8 files changed

+794
-0
lines changed

8 files changed

+794
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Python-generated files
2+
__pycache__/
3+
*.py[oc]
4+
build/
5+
dist/
6+
wheels/
7+
*.egg-info
8+
.ruff_cache/
9+
10+
# Virtual environments
11+
.venv
12+
13+
llm_context.txt

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

README.md

Whitespace-only changes.

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[project]
2+
name = "docs2llm"
3+
version = "0.1.0"
4+
description = "CLI tool to generate LLM context from documentation."
5+
readme = "README.md"
6+
authors = [
7+
{ name = "nklsw" }
8+
]
9+
requires-python = ">=3.11"
10+
dependencies = [
11+
"beautifulsoup4>=4.13.3",
12+
"markdown>=3.8",
13+
"requests>=2.32.3",
14+
"click>=8.1.7",
15+
"rich>=13.7.0",
16+
]
17+
18+
[project.scripts]
19+
docs2llm = "docs2llm.cli:main"
20+
21+
[build-system]
22+
requires = ["hatchling"]
23+
build-backend = "hatchling.build"
24+
25+
[dependency-groups]
26+
dev = [
27+
"ruff>=0.11.5",
28+
]

src/docs2llm/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
docs2llm - Extract documentation from GitHub repositories for use with LLMs.
3+
4+
This package provides functionality to extract documentation from GitHub repositories
5+
and format it for use as context with large language models.
6+
"""
7+
8+
from docs2llm.main import (
9+
extract_documentation,
10+
setup_logging,
11+
is_documentation_file,
12+
markdown_to_text,
13+
clone_repository,
14+
find_documentation_files,
15+
process_documentation_files
16+
)
17+
18+
__version__ = "0.1.0"

src/docs2llm/cli.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import click
4+
from docs2llm.main import extract_documentation, console
5+
6+
@click.command()
7+
@click.argument("path", required=False)
8+
@click.option("--git", help="GitHub repository URL (e.g., https://github.com/owner/repo.git)")
9+
@click.option("--output", default="llm_context.txt", help="Output file name")
10+
@click.option("--max-depth", type=int, default=3, help="Maximum directory depth to search")
11+
@click.option("--branch", help="Specific branch to clone (only used with --git)")
12+
@click.option("--verbose", "-v", is_flag=True, help="Enable verbose logging")
13+
@click.option("--log-file", help="Log to this file in addition to console")
14+
def main(path, git, output, max_depth, branch, verbose, log_file):
15+
"""Generate LLM context from documentation in a directory or GitHub repository.
16+
17+
PATH: Local directory path containing documentation files
18+
19+
You can either provide a local path or use --git with a GitHub repository URL.
20+
Example: --git https://github.com/owner/repo.git
21+
"""
22+
if not path and not git:
23+
console.print("[bold red]Error: Either a local path or --git option must be provided.[/bold red]")
24+
sys.exit(1)
25+
26+
if path and git:
27+
console.print("[bold red]Error: Cannot specify both a local path and --git. Choose one input source.[/bold red]")
28+
sys.exit(1)
29+
30+
success = extract_documentation(
31+
local_path=path,
32+
git_repo=git,
33+
output_file=output,
34+
max_depth=max_depth,
35+
branch=branch,
36+
verbose=verbose,
37+
log_file=log_file
38+
)
39+
40+
# Exit without any success/failure message
41+
sys.exit(0 if success else 1)
42+
43+
44+
if __name__ == "__main__":
45+
main()

0 commit comments

Comments
 (0)