Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lcahlander committed Feb 4, 2022
1 parent 87b8ab4 commit ce56a7a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 228 deletions.
20 changes: 18 additions & 2 deletions src/main/js/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/main/xar-resources/post-install.xq
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ let $a :=
so we can now remove it from the app colllection
:)
return
( xqutil:generate-internal-xqdocs(),
xqutil:generate-external-xqdocs(),
xmldb:remove($target, "collection.xconf"))
xmldb:remove($target, "collection.xconf")
223 changes: 0 additions & 223 deletions src/main/xquery/xqdoc-docbook-lib.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -518,196 +518,7 @@ declare function xqdb:functions($functions as node()*, $module-uri as xs:string?
else
()
}
(:
object-node {
"refVariables" :
array-node {
xqdb:ref-variables($function/xqdoc:ref-variable, $module-uri)
},
"references" :
array-node {
xqdb:all-function-references(
fn:collection($xqdb:XQDOC_COLLECTION)/xqdoc:xqdoc/xqdoc:functions/xqdoc:function/xqdoc:invoked[xqdoc:uri = $module-uri][xqdoc:name = $name],
$module-uri
)
},
}
:)
};

(:~
Generates the JSON for the xqDoc function calls from within a function or a body
@param $invokes
@param $module-uri The URI of the selected module
@author Loren Cahlander
@version 1.0
@since 1.0
declare function xqdb:invoked($invokes as node()*, $module-uri as xs:string?) {
for $uri in fn:distinct-values($invokes/xqdoc:uri/text())
let $trimmed-uri :=
if (fn:starts-with($uri, '"'))
then fn:substring(fn:substring($uri, 1, fn:string-length($uri) - 1), 2)
else $uri
order by $trimmed-uri
return
object-node {
"uri": $trimmed-uri,
"functions":
array-node {
for $invoke in $invokes[xqdoc:uri = $uri]
let $name := $invoke/xqdoc:name/text()
order by $name
return
object-node {
"uri" : $trimmed-uri,
"name" : $name,
"isReachable" :
if (fn:collection($xqdb:XQDOC_COLLECTION)/xqdoc:xqdoc[xqdoc:module/xqdoc:uri = $trimmed-uri][xqdoc:functions/xqdoc:function/xqdoc:name = $name])
then fn:true()
else fn:false(),
"isInternal" :
if ($invoke/xqdoc:uri/text() = $module-uri)
then fn:true()
else fn:false()
}
}
}
};
:)

(:~
Generates the JSON for the xqDoc variable references from within a function or a body
@param $references
@param $module-uri The URI of the selected module
@author Loren Cahlander
@version 1.0
@since 1.0
declare function xqdb:ref-variables($references as node()*, $module-uri as xs:string?) {
for $uri in fn:distinct-values($references/xqdoc:uri/text())
let $trimmed-uri :=
if (fn:starts-with($uri, '"'))
then fn:substring(fn:substring($uri, 1, fn:string-length($uri) - 1), 2)
else $uri
order by $trimmed-uri
return
object-node {
"uri": $uri,
"variables":
array-node {
for $reference in $references[xqdoc:uri = $uri]
let $name := $reference/xqdoc:name/text()
order by $name
return
object-node {
"uri" : $trimmed-uri,
"name" : $name,
"isReachable" :
if (fn:collection($xqdb:XQDOC_COLLECTION)/xqdoc:xqdoc[xqdoc:module/xqdoc:uri = $trimmed-uri][xqdoc:variables/xqdoc:variable/xqdoc:name = $name])
then fn:true()
else fn:false(),
"isInternal" :
if ($reference/xqdoc:uri/text() = $module-uri)
then fn:true()
else fn:false()
}
}
}
};
:)

(:~
@param $references
@param $module-uri The URI of the selected module
@author Loren Cahlander
@version 1.0
@since 1.0
declare function xqdb:all-variable-references($references as node()*, $module-uri as xs:string?) {
let $uris := fn:distinct-values(
for $reference in $references
let $uri := $reference/fn:root()//xqdoc:module/xqdoc:uri/text()
order by $uri
return $uri
)
return
for $uri in $uris
return
object-node {
"uri": $uri,
"functions":
array-node {
for $reference in $references
let $testuri := $reference/fn:root()//xqdoc:module/xqdoc:uri/text()
let $name := $reference/../xqdoc:name/text()
order by $name
return
if ($testuri = $uri)
then
object-node {
"name" : $name,
"uri": $uri,
"isReachable" :
if (fn:collection($xqdb:XQDOC_COLLECTION)/xqdoc:xqdoc[xqdoc:module/xqdoc:uri = $uri][xqdoc:functions/xqdoc:function/xqdoc:name = $name])
then fn:true()
else fn:false(),
"isInternal" :
if ($uri = $module-uri)
then fn:true()
else fn:false()
}
else ()
}
}
};
:)

(:~
@param $references
@param $module-uri The URI of the selected module
@author Loren Cahlander
@version 1.0
@since 1.0
declare function xqdb:all-function-references($references as node()*, $module-uri as xs:string?) {
let $uris := fn:distinct-values(
for $reference in $references
let $uri := $reference/fn:root()//xqdoc:module/xqdoc:uri/text()
order by $uri
return $uri
)
return
for $uri in $uris
return
object-node {
"uri": $uri,
"functions":
array-node {
for $reference in $references
let $testuri := $reference/fn:root()//xqdoc:module/xqdoc:uri/text()
let $name := $reference/../xqdoc:name/text()
order by $name
return
if ($testuri = $uri)
then
object-node {
"name" : $name,
"uri": $uri,
"isReachable" :
if (fn:collection($xqdb:XQDOC_COLLECTION)/xqdoc:xqdoc[xqdoc:module/xqdoc:uri = $uri][xqdoc:functions/xqdoc:function/xqdoc:name = $name])
then fn:true()
else fn:false(),
"isInternal" :
if ($uri = $module-uri)
then fn:true()
else fn:false()
}
else ()
}
}
};
:)

(:~
@param $variables A sequence of the xqdoc:variable elements
Expand Down Expand Up @@ -773,17 +584,6 @@ declare function xqdb:variables($variables as node()*, $module-uri as xs:string?
}
}
}
(:
object-node {
"references" :
array-node {
xqdb:all-variable-references(
fn:collection($xqdb:XQDOC_COLLECTION)/xqdoc:xqdoc/xqdoc:functions/xqdoc:function/xqdoc:ref-variable[xqdoc:uri = $uri][xqdoc:name = $name],
$module-uri
)
}
}
:)
};

(:~
Expand Down Expand Up @@ -898,27 +698,4 @@ as element()
else
()
}
(:
,
document {
object-node {
"response" : if ($doc) then object-node {
"control" : object-node {
"date" : $doc/xqdoc:control/xqdoc:date/text(),
"version" : $doc/xqdoc:control/xqdoc:version/text()
},
"uri": $module,
"invoked" :
array-node {
xqdb:invoked($doc/xqdoc:module/xqdoc:invoked, $module)
},
"refVariables" :
array-node {
xqdb:ref-variables($doc/xqdoc:module/xqdoc:ref-variable, $module)
},
()
} else fn:false()
}
}
:)
};

0 comments on commit ce56a7a

Please sign in to comment.