Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output a gexf file for exploring the import graph #142

Merged
merged 10 commits into from
Nov 1, 2021
12 changes: 12 additions & 0 deletions print_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ def of(cls, fname: str):
def name(self):
return '.'.join(self.parts)

def __str__(self):
return f'{self.project}:{self.name}' # primarily for networkx export

@property
def url(self):
return '/'.join(self.parts) + '.html'
Expand Down Expand Up @@ -706,6 +709,14 @@ def write_decl_txt(loc_map):
with open_outfile('decl.bmp') as out:
out.write('\n'.join(loc_map.keys()))

def write_import_gexf(file_map):
import_graph = env.globals['import_graph'].copy()
for node in import_graph.nodes():
import_graph.nodes[node]['decl_count'] = len(file_map[node])

with open_outfile('import.gexf') as out:
nx.write_gexf(import_graph, out, encoding="unicode")

def mk_export_map_entry(decl_name, filename, kind, is_meta, line, args, tp):
return {'filename': str(filename.raw_path),
'kind': kind,
Expand Down Expand Up @@ -737,6 +748,7 @@ def main():
bib = parse_bib_file(f'{local_lean_root}docs/references.bib')
file_map, loc_map, notes, mod_docs, instances, tactic_docs = load_json()
setup_jinja_globals(file_map, loc_map, instances, bib)
write_import_gexf(file_map)
write_decl_txt(loc_map)
write_html_files(file_map, loc_map, notes, mod_docs, instances, tactic_docs, bib)
write_redirects(loc_map, file_map)
Expand Down