From 6dc75abc56eee2ed6f25dc2f76f56bd1b048b974 Mon Sep 17 00:00:00 2001 From: mellag Date: Fri, 10 Oct 2025 10:28:37 +0200 Subject: [PATCH 1/2] fix: add missing parameter and return's comments when searching everywhere --- src/main/xar-resources/collection.xconf | 2 ++ src/main/xar-resources/modules/app.xqm | 46 ++++++++++++++----------- xar-assembly.xml | 5 +++ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/main/xar-resources/collection.xconf b/src/main/xar-resources/collection.xconf index 7c8152c..a28a29e 100644 --- a/src/main/xar-resources/collection.xconf +++ b/src/main/xar-resources/collection.xconf @@ -7,5 +7,7 @@ + + \ No newline at end of file diff --git a/src/main/xar-resources/modules/app.xqm b/src/main/xar-resources/modules/app.xqm index c794a46..0e754e1 100644 --- a/src/main/xar-resources/modules/app.xqm +++ b/src/main/xar-resources/modules/app.xqm @@ -45,7 +45,7 @@ declare function app:check-not-dba-user-and-not-data($node as node(), $model as if (app:check-user-is-dba() or exists($app:data)) then () else $node }; -declare +declare %templates:default("action", "search") %templates:default("where", "everywhere") function app:action( @@ -78,7 +78,7 @@ function app:search-in-module-location($q as xs:string?) as map(*) { map { "result": $app:data//( xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function - ) + ) } }; @@ -87,7 +87,7 @@ function app:search-in-module-name($q as xs:string?) as map(*) { map { "result": $app:data//( xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function - ) + ) } }; @@ -98,7 +98,7 @@ function app:search-in-description($q as xs:string?) as map(*) { xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)] | xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)] - ) + ) } }; @@ -109,7 +109,7 @@ function app:search-in-signature($q as xs:string?) as map(*) { xqdoc:function[ngram:contains(xqdoc:name, $q)] | xqdoc:function[ngram:contains(xqdoc:signature, $q)] - ) + ) } }; @@ -123,6 +123,10 @@ function app:search-everywhere($q as xs:string?) as map(*) { | xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)] | + xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:param, $q)] + | + xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:return, $q)] + | xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function | xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function @@ -130,11 +134,11 @@ function app:search-everywhere($q as xs:string?) as map(*) { xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)] | xqdoc:module[ngram:contains(xqdoc:name, $q)]/..//xqdoc:function - ) + ) } }; -declare +declare %templates:default("details", "false") function app:module($node as node(), $model as map(*), $details as xs:boolean) { let $functions := $model("result") @@ -144,7 +148,7 @@ function app:module($node as node(), $model as map(*), $details as xs:boolean) { let $location := $module/xqdoc:control/xqdoc:location/text() let $order := (if ($location) then $location else " " || $uri) let $funcsInModule := $module//xqdoc:function intersect $functions - + order by $order return app:print-module($module, $funcsInModule, $details) @@ -153,7 +157,7 @@ function app:module($node as node(), $model as map(*), $details as xs:boolean) { declare %private function app:print-module( $module as element(xqdoc:xqdoc), - $functions as element(xqdoc:function)*, + $functions as element(xqdoc:function)*, $details as xs:boolean ) as element(div) { let $location := $module/xqdoc:control/xqdoc:location/text() @@ -169,7 +173,7 @@ function app:print-module(
@@ -237,7 +241,7 @@ function app:print-function( let $comment := $function/xqdoc:comment let $function-name := $function/xqdoc:name let $arity := xs:integer($function/xqdoc:arity) - let $function-identifier := + let $function-identifier := (: If the name has no prefix, use the name as it is. :) if (contains($function-name, ':')) then ( substring-after($function-name, ":") || "." || $arity @@ -245,11 +249,11 @@ function app:print-function( $function-name || $arity ) let $description := $comment/xqdoc:description/node() - let $parsed := + let $parsed := if (contains($description, '<') or contains($description, '&')) then ( - $description + $description ) else ( - let $constructed-xml := "
" || replace($description, "\n{2,}", "
") || "
" + let $constructed-xml := "
" || replace($description, "\n{2,}", "
") || "
" return parse-xml($constructed-xml)/*/node() ) let $extDocs := app:get-extended-doc($function)[1] @@ -408,7 +412,7 @@ function app:get-extended-module-doc($module as element(xqdoc:xqdoc)) as xs:stri () }; -declare +declare %templates:default("w3c", "false") %templates:default("extensions", "false") %templates:default("appmodules", "false") @@ -420,16 +424,16 @@ function app:showmodules( let $uri := $module/xqdoc:module/xqdoc:uri let $location := $module/xqdoc:control/xqdoc:location order by $uri - return - if ( - ($w3c and starts-with($uri, 'http://www.w3.org')) or + return + if ( + ($w3c and starts-with($uri, 'http://www.w3.org')) or ($appmodules and starts-with($location, '/db')) or ($extensions and app:is-extension($uri, $location)) ) then ( {$uri} {$location} - + ) else () }; @@ -440,7 +444,7 @@ declare function app:is-extension($uri as xs:string, $location as xs:string?) as (starts-with($uri, 'http://exquery.org/ns/') and (empty($location) or starts-with($location, 'java:'))) }; -declare +declare %templates:default("uri", "http://www.w3.org/2005/xpath-functions") %templates:default("details", "false") function app:view( @@ -464,7 +468,7 @@ function app:view( if (empty($function)) then ( app:print-module($module, $module//xqdoc:function, $details cast as xs:boolean) ) else ( - let $functions := + let $functions := if (exists($arity)) then ( $module//xqdoc:function[xqdoc:name eq $function][count(xqdoc:comment/xqdoc:param) = $arity] ) else ( diff --git a/xar-assembly.xml b/xar-assembly.xml index a252c6a..259d455 100644 --- a/xar-assembly.xml +++ b/xar-assembly.xml @@ -18,6 +18,11 @@ prepare.xq finish.xq + +
    +
  • Improve search, looking at parameters and return's comments -
  • +
+
  • Fix an edge case in legacy URL handling - #123
  • From 7527b9de2351922e5da3fa6c492fd89411382581 Mon Sep 17 00:00:00 2001 From: mellag Date: Tue, 14 Oct 2025 09:19:12 +0200 Subject: [PATCH 2/2] add pull url to changelog --- xar-assembly.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xar-assembly.xml b/xar-assembly.xml index 259d455..467ff98 100644 --- a/xar-assembly.xml +++ b/xar-assembly.xml @@ -20,7 +20,7 @@
      -
    • Improve search, looking at parameters and return's comments -
    • +
    • Improve search, looking at parameters and return's comments - #130