[m-rev.] diff: add imports to the xml documentation

Peter Ross pro at missioncriticalit.com
Thu Apr 19 12:08:20 AEST 2007


Hi,


===================================================================


Estimated hours taken: 1
Branches: main

Add XML documentation for the modules an source file
imports.

compiler/xml_documentation.m:
	Add XML documentation for all the imports of a module.
	Output the correct determinism declarations.

mdbcomp/prim_data.m:
	Add all_builtin_modules which lists all the modules
	which are automatically imported.

compiler/unused_imports.m:
	Use all_builtin_modules.


Index: compiler/unused_imports.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unused_imports.m,v
retrieving revision 1.8
diff -u -r1.8 unused_imports.m
--- compiler/unused_imports.m	6 Jan 2007 09:23:58 -0000	1.8
+++ compiler/unused_imports.m	19 Apr 2007 02:03:31 -0000
@@ -80,13 +80,7 @@
     % We also consider the implicitly imported modules to be used as
     % the user cannot do anything about them.
 
-    ImplicitImports = [
-        mercury_public_builtin_module,
-        mercury_private_builtin_module,
-        mercury_table_builtin_module,
-        mercury_profiling_builtin_module,
-        mercury_term_size_prof_builtin_module,
-        mercury_par_builtin_module],
+    ImplicitImports = all_builtin_modules,
     module_info_get_used_modules(ModuleInfo, UsedModules0),
     list.foldl(add_all_modules(visibility_public), ImplicitImports,
         UsedModules0, UsedModules1),
Index: compiler/xml_documentation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/xml_documentation.m,v
retrieving revision 1.12
diff -u -r1.12 xml_documentation.m
--- compiler/xml_documentation.m	19 Jan 2007 07:04:35 -0000	1.12
+++ compiler/xml_documentation.m	19 Apr 2007 02:03:31 -0000
@@ -287,6 +287,15 @@
     (to_xml(module_info_xml_doc(Comments, ModuleComment, ModuleInfo)) = Xml :-
         CommentXml = elem("comment", [], [data(ModuleComment)]),
 
+        module_info_get_interface_module_specifiers(ModuleInfo,
+            InterfaceImports),
+        module_info_get_imported_module_specifiers(ModuleInfo,
+            ImportedModules0),
+        ImportedModules = ImportedModules0 `difference` set(all_builtin_modules),
+        set.fold(import_documentation(InterfaceImports),
+            ImportedModules, [], ImportsXml),
+        ImportXml = elem("imports", [], ImportsXml),
+
         module_info_get_type_table(ModuleInfo, TypeTable),
         map.foldl(type_documentation(Comments), TypeTable, [], TypeXmls),
         TypeXml = elem("types", [], TypeXmls),
@@ -300,13 +309,32 @@
             [], ClassXmls),
         ClassXml = elem("typeclasses", [], ClassXmls),
 
-        Xml = elem("module", [], [CommentXml, TypeXml, PredXml, ClassXml])
+        Children = [CommentXml, ImportXml, TypeXml, PredXml, ClassXml],
+        Xml = elem("module", [], Children)
     )
 ].
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
+    % Output the documentation for one import
+    %
+:- pred import_documentation(set(module_specifier)::in, module_specifier::in,
+    list(xml)::in, list(xml)::out) is det.
+
+import_documentation(InterfaceImportedModules, ImportedModule, !Xmls) :-
+    XmlName = name(ImportedModule),
+    ( ImportedModule `member` InterfaceImportedModules ->
+        XmlVisibility = visibility(status_exported)
+    ;
+        XmlVisibility = visibility(status_local)
+    ),
+    Xml = elem("import", [], [XmlName, XmlVisibility]),
+    !:Xmls = [Xml | !.Xmls].
+    
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
     % Output the documentation of one type.
     %
 :- pred type_documentation(comments::in, type_ctor::in, hlds_type_defn::in,
@@ -611,10 +639,10 @@
 :- func determinism(determinism) = xml.
 
 determinism(detism_det) = tagged_string("determinism", "det").
-determinism(detism_semi) = tagged_string("determinism", "semi").
+determinism(detism_semi) = tagged_string("determinism", "semidet").
 determinism(detism_multi) = tagged_string("determinism", "multi").
-determinism(detism_non) = tagged_string("determinism", "non").
-determinism(detism_cc_non) = tagged_string("determinism", "cc_non").
+determinism(detism_non) = tagged_string("determinism", "nondet").
+determinism(detism_cc_non) = tagged_string("determinism", "cc_nondet").
 determinism(detism_cc_multi) = tagged_string("determinism", "cc_multi").
 determinism(detism_erroneous) = tagged_string("determinism", "erroneous").
 determinism(detism_failure) = tagged_string("determinism", "failure").
Index: mdbcomp/prim_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/mdbcomp/prim_data.m,v
retrieving revision 1.19
diff -u -r1.19 prim_data.m
--- mdbcomp/prim_data.m	19 Jan 2007 07:05:05 -0000	1.19
+++ mdbcomp/prim_data.m	19 Apr 2007 02:03:32 -0000
@@ -18,6 +18,8 @@
 
 :- interface.
 
+:- import_module list.
+
     % This enumeration must be EXACTLY the same as the MR_PredFunc enum
     % in runtime/mercury_stack_layout.h, and in the same order, since the
     % code (in browser) assumes the representation is the same.
@@ -170,6 +172,10 @@
     %
 :- func insert_module_qualifier(string, sym_name) = sym_name.
 
+    % Returns all the modules which are automatically imported.
+    %
+:- func all_builtin_modules = list(sym_name).
+
     % Returns the name of the module containing public builtins;
     % originally this was "mercury_builtin", but it later became
     % just "builtin", and it may eventually be renamed "std.builtin".
@@ -286,6 +292,14 @@
 
 get_special_pred_id_arity(Id) = Arity :-
         special_pred_name_arity(Id, _, _, Arity).
+
+all_builtin_modules = [
+        mercury_public_builtin_module,
+        mercury_private_builtin_module,
+        mercury_table_builtin_module,
+        mercury_profiling_builtin_module,
+        mercury_term_size_prof_builtin_module,
+        mercury_par_builtin_module].
 
 % We may eventually want to put the standard library into a package "std":
 % mercury_public_builtin_module = qualified(unqualified("std"), "builtin").

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list