forked from KolibriOS/kolibrios
[kernel] Make asmxygen generate doxygen C-like files in docs/doxygen and implement very basic variable doxygen generation
git-svn-id: svn://kolibrios.org@8834 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7357d51930
commit
3f88024a1b
@ -1,29 +1,12 @@
|
|||||||
import os
|
|
||||||
from glob import glob
|
|
||||||
|
|
||||||
"""
|
|
||||||
# Collect all .inc files
|
|
||||||
kernel_files = [y for x in os.walk(".") for y in glob(os.path.join(x[0], '*.inc'))]
|
|
||||||
|
|
||||||
to_remove = []
|
|
||||||
for i in range(len(kernel_files)):
|
|
||||||
inc = kernel_files[i]
|
|
||||||
# Remove files that aren't a part of the kernel
|
|
||||||
if "bootloader" in inc or "sec_loader" in inc:
|
|
||||||
to_remove.append(i)
|
|
||||||
|
|
||||||
for i in range(len(to_remove) - 1, -1, -1):
|
|
||||||
kernel_files.pop(to_remove[i])
|
|
||||||
|
|
||||||
# Add main kernel file
|
|
||||||
kernel_files.append("kernel.asm")
|
|
||||||
|
|
||||||
# Add main kernel file
|
|
||||||
# TODO: Rename the file so it won't be an exception
|
|
||||||
kernel_files.append("fs/xfs.asm")
|
|
||||||
"""
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Parameters
|
||||||
|
doxygen_src_path = 'docs/doxygen'
|
||||||
|
link_root = "http://websvn.kolibrios.org/filedetails.php?repname=Kolibri+OS&path=/kernel/trunk"
|
||||||
|
clean_generated_stuff = True # Remove generated doxygen files if True
|
||||||
|
dump_symbols = False
|
||||||
|
print_stats = False
|
||||||
|
|
||||||
# kernel_structure["filename"] = {
|
# kernel_structure["filename"] = {
|
||||||
# [ [], # [0] Variables - [ line, name ]
|
# [ [], # [0] Variables - [ line, name ]
|
||||||
@ -63,7 +46,6 @@ def get_declarations(asm_file_contents, asm_file_name):
|
|||||||
match = macro_pattern.findall(line)
|
match = macro_pattern.findall(line)
|
||||||
if len(match) > 0:
|
if len(match) > 0:
|
||||||
macro_name = match[0]
|
macro_name = match[0]
|
||||||
#print(f"Macro '{macro_name}' at {line_idx + 1}")
|
|
||||||
kernel_structure[asm_file_name][MACROS].append([ line_idx + 1, macro_name ])
|
kernel_structure[asm_file_name][MACROS].append([ line_idx + 1, macro_name ])
|
||||||
end_of_macro = False
|
end_of_macro = False
|
||||||
while not end_of_macro:
|
while not end_of_macro:
|
||||||
@ -79,7 +61,6 @@ def get_declarations(asm_file_contents, asm_file_name):
|
|||||||
match = proc_pattern.findall(line)
|
match = proc_pattern.findall(line)
|
||||||
if len(match) > 0:
|
if len(match) > 0:
|
||||||
proc_name = match[0]
|
proc_name = match[0]
|
||||||
#print(f"Procedure '{proc_name}' at {line_idx + 1}")
|
|
||||||
kernel_structure[asm_file_name][PROCEDURES].append([ line_idx + 1, proc_name ])
|
kernel_structure[asm_file_name][PROCEDURES].append([ line_idx + 1, proc_name ])
|
||||||
line_idx += 1
|
line_idx += 1
|
||||||
continue
|
continue
|
||||||
@ -89,7 +70,6 @@ def get_declarations(asm_file_contents, asm_file_name):
|
|||||||
label_name = match[0]
|
label_name = match[0]
|
||||||
# Don't count local labels
|
# Don't count local labels
|
||||||
if label_name[0] != '.':
|
if label_name[0] != '.':
|
||||||
#print(f"Label '{label_name}' at {line_idx + 1}")
|
|
||||||
kernel_structure[asm_file_name][LABELS].append([ line_idx + 1, label_name ])
|
kernel_structure[asm_file_name][LABELS].append([ line_idx + 1, label_name ])
|
||||||
line_idx += 1
|
line_idx += 1
|
||||||
continue
|
continue
|
||||||
@ -97,7 +77,6 @@ def get_declarations(asm_file_contents, asm_file_name):
|
|||||||
match = struct_pattern.findall(line)
|
match = struct_pattern.findall(line)
|
||||||
if len(match) > 0:
|
if len(match) > 0:
|
||||||
struct_name = match[0]
|
struct_name = match[0]
|
||||||
#print(f"Structure '{struct_name}' at {line_idx + 1}")
|
|
||||||
kernel_structure[asm_file_name][STRUCTURES].append([ line_idx + 1, struct_name ])
|
kernel_structure[asm_file_name][STRUCTURES].append([ line_idx + 1, struct_name ])
|
||||||
end_of_struct = False
|
end_of_struct = False
|
||||||
while not end_of_struct:
|
while not end_of_struct:
|
||||||
@ -109,7 +88,7 @@ def get_declarations(asm_file_contents, asm_file_name):
|
|||||||
|
|
||||||
line_idx += 1
|
line_idx += 1
|
||||||
|
|
||||||
def get_includes(handled_files, asm_file_name, subdir = "."):
|
def handle_file(handled_files, asm_file_name, subdir = "."):
|
||||||
print(f"Handling {asm_file_name}")
|
print(f"Handling {asm_file_name}")
|
||||||
handled_files.append(asm_file_name)
|
handled_files.append(asm_file_name)
|
||||||
try:
|
try:
|
||||||
@ -126,13 +105,14 @@ def get_includes(handled_files, asm_file_name, subdir = "."):
|
|||||||
full_path = subdir + '/' + include;
|
full_path = subdir + '/' + include;
|
||||||
if full_path not in handled_files:
|
if full_path not in handled_files:
|
||||||
new_subdir = full_path.rsplit('/', 1)[0]
|
new_subdir = full_path.rsplit('/', 1)[0]
|
||||||
get_includes(handled_files, full_path, new_subdir)
|
handle_file(handled_files, full_path, new_subdir)
|
||||||
return handled_files
|
return handled_files
|
||||||
|
|
||||||
kernel_files = []
|
kernel_files = []
|
||||||
|
|
||||||
get_includes(kernel_files, "./kernel.asm");
|
handle_file(kernel_files, "./kernel.asm");
|
||||||
|
|
||||||
|
if dump_symbols:
|
||||||
for source in kernel_structure:
|
for source in kernel_structure:
|
||||||
print(f"File: {source}")
|
print(f"File: {source}")
|
||||||
if len(kernel_structure[source][VARIABLES]) > 0:
|
if len(kernel_structure[source][VARIABLES]) > 0:
|
||||||
@ -156,6 +136,7 @@ for source in kernel_structure:
|
|||||||
for struct in kernel_structure[source][STRUCTURES]:
|
for struct in kernel_structure[source][STRUCTURES]:
|
||||||
print(f" {struct[0]}: {struct[1]}")
|
print(f" {struct[0]}: {struct[1]}")
|
||||||
|
|
||||||
|
if print_stats:
|
||||||
# Collect stats
|
# Collect stats
|
||||||
var_count = 0
|
var_count = 0
|
||||||
proc_count = 0
|
proc_count = 0
|
||||||
@ -176,5 +157,45 @@ print(f"Global labels count: {label_count}")
|
|||||||
print(f"Macroses count: {macro_count}")
|
print(f"Macroses count: {macro_count}")
|
||||||
print(f"Structures count: {struct_count}")
|
print(f"Structures count: {struct_count}")
|
||||||
|
|
||||||
#for kernel_file in kernel_files:
|
print(f"Writing doumented sources to {doxygen_src_path}")
|
||||||
# print(kernel_file)
|
|
||||||
|
created_files = []
|
||||||
|
|
||||||
|
def write_variable(source, line, name, type = "int", brief = "Undocumented",
|
||||||
|
init = None):
|
||||||
|
source = source.replace("./", "")
|
||||||
|
full_path = doxygen_src_path + '/' + source
|
||||||
|
# Remove the file on first access if it was created by previous generation
|
||||||
|
if full_path not in created_files:
|
||||||
|
if os.path.isfile(full_path):
|
||||||
|
os.remove(full_path)
|
||||||
|
created_files.append(full_path)
|
||||||
|
# Only remove the file on 'clean_generated_stuff' flag (removed above, just return)
|
||||||
|
if clean_generated_stuff: return
|
||||||
|
# Create directories need for the file
|
||||||
|
os.makedirs(os.path.dirname(full_path), exist_ok=True)
|
||||||
|
name = name.replace(".", "_")
|
||||||
|
f = open(full_path, "a")
|
||||||
|
f.write(f"/**\n")
|
||||||
|
f.write(f" * @brief {brief}\n")
|
||||||
|
f.write(f" * @par Initial value\n")
|
||||||
|
f.write(f" * {init}\n")
|
||||||
|
f.write(f" * @par Source\n")
|
||||||
|
f.write(f" * <a href='{link_root}/{source}#line-{line}'>{source}:{line}</a>\n")
|
||||||
|
f.write(f" */\n")
|
||||||
|
if init == None:
|
||||||
|
set_init = ""
|
||||||
|
else:
|
||||||
|
set_init = f" = {init}"
|
||||||
|
f.write(f"{type} {name}{set_init};\n\n")
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
i = 1
|
||||||
|
for source in kernel_structure:
|
||||||
|
# Print progress: current/total
|
||||||
|
print(f"{i}/{len(kernel_structure)} Writing {source}")
|
||||||
|
# Write variables doxygen of the source file
|
||||||
|
if len(kernel_structure[source][VARIABLES]) > 0:
|
||||||
|
for variable in kernel_structure[source][VARIABLES]:
|
||||||
|
write_variable(source, variable[0], variable[1])
|
||||||
|
i += 1
|
||||||
|
2612
kernel/trunk/docs/doxygen/doxygen.cfg
Normal file
2612
kernel/trunk/docs/doxygen/doxygen.cfg
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user