Ответ 1
У меня есть немного кода, который я использую для создания индексного файла из проекта. Это не совсем то, что вы ищете, но с небольшим завихрением вы можете добавить инструкцию if для файлов py (где у меня есть только html и png) и захватить doc= "ваш DocStrings."... https://gist.github.com/Krewn/6e9acdadddb4bf2a56c0
# WARNING RUNNING THIS FILE WILL OVERIDE EXISTING readme.md FILE IN CWD
import os
class indexer:
path = "~"
username = "" # !!! Enter your github username in the provided quotes.
site = "http://"+username+".github.io"
proj = "" # !!! Enter your repository name in provided quotes.
prod = []
loc=[]
def __init__(self,p):
self.path=p
def fprep(self,name):
name.replace(".","")
name.replace("\\","/")
return(name)
def refPrep(self):
ref = self.site+"/"+self.proj
for qw in self.loc:
ref+="/"+qw
return(ref)
def HtmlFrek(self,adir):
self.loc.append(adir)
os.chdir(adir)
pys = [f for f in os.listdir('.') if os.path.isfile(f) and f.split(".")[len(f.split("."))-1]=="py"]
for i in pys:
Open the file i get the __doc__ string and append it to ret
for k in folders:
if(k.__contains__(".")):
continue
ret+=self.HtmlFrek(k)
os.chdir("..")
del self.loc[len(self.loc)-1]
return(ret)
def HtmlProd(self):
ret = ""
pys = [f for f in os.listdir('.') if os.path.isfile(f) and f.split(".")[len(f.split("."))-1]=="py"]
for i in pys:
Open the file i get the __doc__ string and append it to ret
folders = [f for f in os.listdir(".") if not os.path.isfile(f)]
for k in folders:
if(k.__contains__(".")):
continue
ret+=self.HtmlFrek(k)
self.prod = ret
return(ret)
i = indexer(".")
q=i.HtmlProd()
#print i.prod
w = open("readme.md","w")
w.write(q)
w.close()