mirror of
https://github.com/Ragora/TSScraper.git
synced 2026-07-16 02:24:35 +00:00
Initial commit.
This commit is contained in:
commit
c149d6bad8
6 changed files with 329 additions and 0 deletions
1
exporters/__init__.py
Normal file
1
exporters/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
64
exporters/doku.py
Normal file
64
exporters/doku.py
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import re
|
||||
import os
|
||||
import sys
|
||||
import importlib
|
||||
import os.path
|
||||
|
||||
class Exporter(object):
|
||||
data = None
|
||||
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def write(self):
|
||||
with open("Out.txt", "w") as handle:
|
||||
# Write the header
|
||||
handle.write("====== Test ======\n\n")
|
||||
|
||||
# For each file entry...
|
||||
for file in self.data:
|
||||
if (len(file.global_functions) == 0 and len(file.bound_functions.keys()) == 0 and len(file.datablocks) == 0):
|
||||
continue
|
||||
|
||||
# Calculate the total entry count
|
||||
entry_count = len(file.global_functions) + len(file.datablocks)
|
||||
for type in file.bound_functions.keys():
|
||||
entry_count = entry_count + len(file.bound_functions[type])
|
||||
|
||||
handle.write("===== Entries in %s (%u total) =====\n\n" % (file.path, entry_count))
|
||||
handle.write("===== Global Functions (%u total) =====\n\n" % len(file.global_functions))
|
||||
|
||||
# For each global function...
|
||||
for function in file.global_functions:
|
||||
handle.write("==== %s ====\n" % function.name)
|
||||
handle.write("File (line %u): %s\n\n" % (function.line, file.path))
|
||||
|
||||
if (len(function.parameters) != 0):
|
||||
handle.write("Parameters (in order):\n")
|
||||
|
||||
for parameter in function.parameters:
|
||||
handle.write(" * %s\n" % parameter)
|
||||
else:
|
||||
handle.write("Parameters: None\n")
|
||||
|
||||
handle.write("\n")
|
||||
|
||||
# For each known type...
|
||||
for type in file.bound_functions.keys():
|
||||
handle.write("===== Bound Functions on %s (%u total) =====\n\n" % (type, len(file.bound_functions[type])))
|
||||
# For each function for this type...
|
||||
for function in file.bound_functions[type]:
|
||||
handle.write("==== %s::%s ====\n" % (function.type, function.name))
|
||||
handle.write("File (line %u): %s\n\n" % (function.line, file.path))
|
||||
|
||||
if (len(function.parameters) != 0):
|
||||
handle.write("Parameters (in order):\n")
|
||||
|
||||
for parameter in function.parameters:
|
||||
handle.write(" * %s\n" % parameter)
|
||||
else:
|
||||
handle.write("Parameters: None\n")
|
||||
|
||||
handle.write("\n")
|
||||
|
||||
print("Done processing.")
|
||||
46
exporters/html.py
Normal file
46
exporters/html.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import re
|
||||
import os
|
||||
import sys
|
||||
import importlib
|
||||
import os.path
|
||||
|
||||
class Exporter(object):
|
||||
data = None
|
||||
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def write(self):
|
||||
import jinja2
|
||||
|
||||
# Read the template files first
|
||||
file_template = None
|
||||
with open("data/filetempl.html", "r") as handle:
|
||||
file_template = handle.read()
|
||||
|
||||
index_template = None
|
||||
with open("data/indextempl.html", "r") as handle:
|
||||
index_template = handle.read()
|
||||
|
||||
html_filenames = [ ]
|
||||
# For each file entry...
|
||||
for file in self.data:
|
||||
if (len(file.global_functions) == 0 and len(file.bound_functions.keys()) == 0 and len(file.datablocks) == 0):
|
||||
continue
|
||||
|
||||
html_filename = file.path.lstrip("./").replace("/", "-")
|
||||
html_filename, oldextension = os.path.splitext(html_filename)
|
||||
html_filename = "%s.html" % html_filename
|
||||
html_filenames.append(html_filename)
|
||||
|
||||
with open(html_filename, "w") as handle:
|
||||
template = jinja2.Template(file_template)
|
||||
handle.write(template.render(file=file.path, globals=file.global_functions))
|
||||
|
||||
# Dump the index file
|
||||
with open("index.html", "w") as handle:
|
||||
template = jinja2.Template(index_template)
|
||||
handle.write(template.render(files=self.data))
|
||||
|
||||
print("Done processing.")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue