@@ -757,9 +757,9 @@ def mk_export_map_entry(decl_name, filename, kind, is_meta, line, args, tp):
757
757
'src_link' : library_link (filename , line ),
758
758
'docs_link' : f'{ site_root } { filename .url } #{ decl_name } ' }
759
759
760
- def mk_export_db (loc_map , file_map ):
760
+ def mk_export_db (file_map ):
761
761
export_db = {}
762
- for fn , decls in file_map .items ():
762
+ for _ , decls in file_map .items ():
763
763
for obj in decls :
764
764
export_db [obj ['name' ]] = mk_export_map_entry (obj ['name' ], obj ['filename' ], obj ['kind' ], obj ['is_meta' ], obj ['line' ], obj ['args' ], obj ['type' ])
765
765
export_db [obj ['name' ]]['decl_header_html' ] = env .get_template ('decl_header.j2' ).render (decl = obj )
@@ -774,6 +774,44 @@ def write_export_db(export_db):
774
774
with gzip .GzipFile (html_root + 'export_db.json.gz' , 'w' ) as zout :
775
775
zout .write (json_str .encode ('utf-8' ))
776
776
777
+ def mk_export_searchable_map_entry (filename_name , name , description , kind = '' , attributes = []):
778
+ return {
779
+ 'module' : filename_name ,
780
+ 'name' : name ,
781
+ 'description' : description ,
782
+ 'kind' : kind ,
783
+ 'attributes' : attributes ,
784
+ }
785
+
786
+ def mk_export_searchable_db (file_map , tactic_docs ):
787
+ export_searchable_db = []
788
+
789
+ for fn , decls in file_map .items ():
790
+ filename_name = str (fn .url )
791
+ for obj in decls :
792
+ decl_entry = mk_export_searchable_map_entry (filename_name , obj ['name' ], obj ['doc_string' ], obj ['kind' ], obj ['attributes' ])
793
+ export_searchable_db .append (decl_entry )
794
+ for (cstr_name , _ ) in obj ['constructors' ]:
795
+ cstr_entry = mk_export_searchable_map_entry (filename_name , cstr_name , obj ['doc_string' ], obj ['kind' ], obj ['attributes' ])
796
+ export_searchable_db .append (cstr_entry )
797
+ for (sf_name , _ ) in obj ['structure_fields' ]:
798
+ sf_entry = mk_export_searchable_map_entry (filename_name , sf_name , obj ['doc_string' ], obj ['kind' ], obj ['attributes' ])
799
+ export_searchable_db .append (sf_entry )
800
+
801
+ for tactic in tactic_docs :
802
+ # category is the singular form of each docs webpage in 'General documentation'
803
+ # e.g. 'tactic' -> 'tactics.html'
804
+ tactic_entry_container_name = f"{ tactic ['category' ]} s.html"
805
+ tactic_entry = mk_export_searchable_map_entry (tactic_entry_container_name , tactic ['name' ], tactic ['description' ])
806
+ export_searchable_db .append (tactic_entry )
807
+
808
+ return export_searchable_db
809
+
810
+ def write_export_searchable_db (searchable_data ):
811
+ json_str = json .dumps (searchable_data )
812
+ with open_outfile ('searchable_data.bmp' ) as out :
813
+ out .write (json_str )
814
+
777
815
def main ():
778
816
bib = parse_bib_file (f'{ local_lean_root } docs/references.bib' )
779
817
file_map , loc_map , notes , mod_docs , instances , tactic_docs = load_json ()
@@ -785,7 +823,8 @@ def main():
785
823
copy_css_and_js (html_root , use_symlinks = cl_args .l )
786
824
copy_yaml_bib_files (html_root )
787
825
copy_static_files (html_root )
788
- write_export_db (mk_export_db (loc_map , file_map ))
826
+ write_export_db (mk_export_db (file_map ))
827
+ write_export_searchable_db (mk_export_searchable_db (file_map , tactic_docs ))
789
828
write_site_map (file_map )
790
829
791
830
if __name__ == '__main__' :
0 commit comments