-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomation.py
More file actions
39 lines (34 loc) · 1.21 KB
/
Copy pathautomation.py
File metadata and controls
39 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import os
from crewai import Agent
def gerar_documentacao():
prompt = "Analise todo o código deste repositório e gere uma documentação detalhada e concisa."
agente = Agent(
role="Documentador",
goal="Gerar documentação completa do código",
backstory="Você é um especialista em análise e documentação de código.",
verbose=True,
allow_delegation=False,
)
resposta = agente.run(prompt)
return resposta
def atualizar_readme(conteudo):
arquivo = "README.md"
try:
with open(arquivo, "r", encoding="utf-8") as f:
linhas = f.readlines()
except FileNotFoundError:
print(f"{arquivo} não encontrado.")
return
try:
inicio = linhas.index("<!-- DOC START -->\n") + 1
fim = linhas.index("<!-- DOC END -->\n")
except ValueError:
print("Tags <!-- DOC START --> e <!-- DOC END --> não encontradas no README.md")
return
novas_linhas = linhas[:inicio] + [conteudo + "\n"] + linhas[fim:]
with open(arquivo, "w", encoding="utf-8") as f:
f.writelines(novas_linhas)
if __name__ == "__main__":
docs = gerar_documentacao()
atualizar_readme(docs)