src/doc/api: add links to renderer code
[nit.git] / src / doc / doc_phases / doc_indexing.nit
index 9e9ef3c..8719011 100644 (file)
 # Manage indexing of Nit model for Nitdoc QuickSearch.
 module doc_indexing
 
-import doc_extract
+import doc_base
+import html_templates::html_model # FIXME maybe this phase should depend on `html_render`
 private import json::static
+private import json
 
 # Generate the index for then Nitdoc QuickSearch field.
 #
@@ -31,18 +33,18 @@ class IndexingPhase
        super DocPhase
 
        redef fun apply do
-               for mmodule in doc.mmodules do
+               for mmodule in doc.model.mmodules do
                        add_result_for(mmodule.name, mmodule.full_name, mmodule.nitdoc_url)
                end
-               for mclass in doc.mclasses do
+               for mclass in doc.model.mclasses do
                        add_result_for(mclass.name, mclass.full_name, mclass.nitdoc_url)
                end
-               for mproperty in doc.mproperties do
+               for mproperty in doc.model.mproperties do
                        for mpropdef in mproperty.mpropdefs do
-                               if not doc.mpropdefs.has(mpropdef) then continue
+                               if not doc.filter.accept_mentity(mpropdef) then continue
                                var full_name = mpropdef.mclassdef.mclass.full_name
                                var cls_url = mpropdef.mclassdef.mclass.nitdoc_url
-                               var def_url = "{cls_url}#{mpropdef.mproperty.nitdoc_id}"
+                               var def_url = "{cls_url}#{mpropdef.nitdoc_id}.definition"
                                add_result_for(mproperty.name, full_name, def_url)
                        end
                end
@@ -63,10 +65,10 @@ class IndexingPhase
        # Render the index content.
        fun render: Template do
                var tpl = new Template
-               var buffer = new RopeBuffer
+               var buffer = new Buffer
                tpl.add buffer
                buffer.append "var nitdocQuickSearchRawList="
-               table.append_json buffer
+               buffer.append table.to_json
                buffer.append ";"
                return tpl
        end
@@ -79,6 +81,7 @@ private class QuickSearchTable
 
        redef fun provide_default_value(key) do
                var v = new QuickSearchResultList
+               assert key isa String
                self[key] = v
                return v
        end
@@ -92,15 +95,11 @@ end
 
 # A QuickSearch result.
 private class QuickSearchResult
-       super Jsonable
+       serialize
 
        # The text of the link.
        var txt: String
 
        # The destination of the link.
        var url: String
-
-       redef fun to_json do
-               return "\{\"txt\":{txt.to_json},\"url\":{url.to_json}\}"
-       end
 end