Add .env file loading — cp .env.example .env and edit
This commit is contained in:
10
docgen.py
10
docgen.py
@@ -4,6 +4,16 @@ import requests
|
|||||||
import os
|
import os
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
import time
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Load .env if present
|
||||||
|
_env_file = Path(__file__).parent / ".env"
|
||||||
|
if _env_file.exists():
|
||||||
|
for line in _env_file.read_text().splitlines():
|
||||||
|
line = line.strip()
|
||||||
|
if line and not line.startswith("#") and "=" in line:
|
||||||
|
key, _, val = line.partition("=")
|
||||||
|
os.environ.setdefault(key.strip(), val.strip())
|
||||||
|
|
||||||
# Backend: "ollama" or "openai"
|
# Backend: "ollama" or "openai"
|
||||||
LLM_BACKEND = os.environ.get("LLM_BACKEND", "ollama")
|
LLM_BACKEND = os.environ.get("LLM_BACKEND", "ollama")
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ import time
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Load .env if present
|
||||||
|
_env_file = Path(__file__).parent / ".env"
|
||||||
|
if _env_file.exists():
|
||||||
|
for line in _env_file.read_text().splitlines():
|
||||||
|
line = line.strip()
|
||||||
|
if line and not line.startswith("#") and "=" in line:
|
||||||
|
key, _, val = line.partition("=")
|
||||||
|
os.environ.setdefault(key.strip(), val.strip())
|
||||||
|
|
||||||
from go_parser import parse_go_file, filter_imports, get_repo_module, resolve_import_to_file
|
from go_parser import parse_go_file, filter_imports, get_repo_module, resolve_import_to_file
|
||||||
from docgen import generate_file_doc, generate_repo_doc, generate_docs_batch
|
from docgen import generate_file_doc, generate_repo_doc, generate_docs_batch
|
||||||
from db import GraphDB
|
from db import GraphDB
|
||||||
|
|||||||
Reference in New Issue
Block a user