-
Notifications
You must be signed in to change notification settings - Fork 2
/
python_manual_hook.py
executable file
·45 lines (40 loc) · 1.38 KB
/
python_manual_hook.py
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
40
41
42
43
44
45
import logging
import mkdocs.plugins
import os
log = logging.getLogger('mkdocs')
@mkdocs.plugins.event_priority(-50)
def on_startup(command, dirty):
template = """
---
title: Automatically Generated Python Documentation
summary: DO NOT EDIT THIS FILE MANUALLY : It is created during the mkdocs build process
date: 2023-08-03
---
# Python Reference Manual
"""
ignore_list = [
"__init__",
"migrations",
"tests"]
for root, dirs, files in os.walk("../django_project"):
for file in files:
file = os.path.join(root, file)
ignored = False;
if file.endswith(".py"):
for item in ignore_list:
if item in file:
ignored = True;
#print (item, file, ignored)
if not ignored:
file = file.replace("../django_project/", "::: ")
file = file.replace("/", ".")
file = file.replace(".py", "")
template = template + file + "\n"
output_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"src/developer/manual/index.md")
log.info("Manual will be written to: " + output_path)
file = open(output_path,"wt+")
file.write(template)
file.close()
log.info("Manual written to: " + os.path.realpath(file.name))