I am looking to generate documentation from the system module stubs in etc/modules.zip.
I have two issues

1) There is an issue with inspect.xqm

declare namespace xqdoc="http://www.xqdoc.org/1.0";
let $a:=inspect:xqdoc("inspect.xqm")//xqdoc:function[xqdoc:name='inspect:xqdoc']//xqdoc:description
return parse-xml-fragment($a)

Errors
And xqdoc:description looks like
<xqdoc:description xmlns:xqdoc="http://www.xqdoc.org/1.0">&lt;/code&gt; and end with &lt;code&gt;&lt;/code&gt; , and tags start with &lt;code&gt;@&lt;/code&gt; . xqDoc comments can be specified for main and library modules and variable and function declarations.
&lt;p&gt;We have slightly extended the xqDoc conventions to do justice to the current status of XQuery (Schema: &lt;a href="http://files.basex.org/etc/xqdoc-1.1.30052013.xsd"&gt;xqdoc-1.1.30052013.xsd&lt;/a&gt;):
&lt;/p&gt;  &lt;ul&gt; &lt;li&gt; an &lt;code&gt;&amp;lt;xqdoc:annotations/&amp;gt;&lt;/code&gt; node is added to each variable or function that uses annotations. The xqdoc:annotation child nodes may have additional &lt;code&gt;xqdoc:literal&lt;/code&gt; elements with &lt;code&gt;type&lt;/code&gt; attributes (xs:string, xs:integer, xs:decimal, xs:double) and values. &lt;/li&gt; &lt;li&gt; a single &lt;code&gt;&amp;lt;xqdoc:namespaces/&amp;gt;&lt;/code&gt; node is added to the root element, which summarizes all prefixes and namespace URIs used or declared in the module. &lt;/li&gt; &lt;li&gt; name and type elements are added to variables &lt;/li&gt; &lt;/ul&gt;</xqdoc:description>

A comment parsing/escaping issue?

2) inspect:xqdoc("array.xqm") and the same with map.xqm

Function 'array:size' is in reserved namespace. I guess this is to be expected and maybe I should just ignore any  modules in namespaces http://www.w3.org/... 
I guess it is a result of the code being compiled rather than just documented?

/Andy