Skip to content

Commit c9e990a

Browse files
authored
Merge pull request #130 from gmella/master
fix: add missing parameter and return's comments when searching
2 parents dc87d21 + 7527b9d commit c9e990a

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

src/main/xar-resources/collection.xconf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
<ngram qname="xqdoc:name"/>
88
<ngram qname="xqdoc:signature"/>
99
<ngram qname="xqdoc:description"/>
10+
<ngram qname="xqdoc:param"/>
11+
<ngram qname="xqdoc:return"/>
1012
</index>
1113
</collection>

src/main/xar-resources/modules/app.xqm

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ declare function app:check-not-dba-user-and-not-data($node as node(), $model as
4545
if (app:check-user-is-dba() or exists($app:data)) then () else $node
4646
};
4747

48-
declare
48+
declare
4949
%templates:default("action", "search")
5050
%templates:default("where", "everywhere")
5151
function app:action(
@@ -78,7 +78,7 @@ function app:search-in-module-location($q as xs:string?) as map(*) {
7878
map {
7979
"result": $app:data//(
8080
xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function
81-
)
81+
)
8282
}
8383
};
8484

@@ -87,7 +87,7 @@ function app:search-in-module-name($q as xs:string?) as map(*) {
8787
map {
8888
"result": $app:data//(
8989
xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function
90-
)
90+
)
9191
}
9292
};
9393

@@ -98,7 +98,7 @@ function app:search-in-description($q as xs:string?) as map(*) {
9898
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
9999
|
100100
xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
101-
)
101+
)
102102
}
103103
};
104104

@@ -109,7 +109,7 @@ function app:search-in-signature($q as xs:string?) as map(*) {
109109
xqdoc:function[ngram:contains(xqdoc:name, $q)]
110110
|
111111
xqdoc:function[ngram:contains(xqdoc:signature, $q)]
112-
)
112+
)
113113
}
114114
};
115115

@@ -123,18 +123,22 @@ function app:search-everywhere($q as xs:string?) as map(*) {
123123
|
124124
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
125125
|
126+
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:param, $q)]
127+
|
128+
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:return, $q)]
129+
|
126130
xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function
127131
|
128132
xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function
129133
|
130134
xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
131135
|
132136
xqdoc:module[ngram:contains(xqdoc:name, $q)]/..//xqdoc:function
133-
)
137+
)
134138
}
135139
};
136140

137-
declare
141+
declare
138142
%templates:default("details", "false")
139143
function app:module($node as node(), $model as map(*), $details as xs:boolean) {
140144
let $functions := $model("result")
@@ -144,7 +148,7 @@ function app:module($node as node(), $model as map(*), $details as xs:boolean) {
144148
let $location := $module/xqdoc:control/xqdoc:location/text()
145149
let $order := (if ($location) then $location else " " || $uri)
146150
let $funcsInModule := $module//xqdoc:function intersect $functions
147-
151+
148152
order by $order
149153
return
150154
app:print-module($module, $funcsInModule, $details)
@@ -153,7 +157,7 @@ function app:module($node as node(), $model as map(*), $details as xs:boolean) {
153157
declare %private
154158
function app:print-module(
155159
$module as element(xqdoc:xqdoc),
156-
$functions as element(xqdoc:function)*,
160+
$functions as element(xqdoc:function)*,
157161
$details as xs:boolean
158162
) as element(div) {
159163
let $location := $module/xqdoc:control/xqdoc:location/text()
@@ -169,7 +173,7 @@ function app:print-module(
169173
<div class="module-head">
170174
<div class="module-head-inner row">
171175
<div class="col-md-1 hidden-xs">
172-
<a href="view?uri={$uri}&amp;location={$location}&amp;details=true"
176+
<a href="view?uri={$uri}&amp;location={$location}&amp;details=true"
173177
class="module-info-icon"><span class="glyphicon glyphicon-info-sign"/></a>
174178
</div>
175179
<div class="col-md-11 col-xs-12">
@@ -237,19 +241,19 @@ function app:print-function(
237241
let $comment := $function/xqdoc:comment
238242
let $function-name := $function/xqdoc:name
239243
let $arity := xs:integer($function/xqdoc:arity)
240-
let $function-identifier :=
244+
let $function-identifier :=
241245
(: If the name has no prefix, use the name as it is. :)
242246
if (contains($function-name, ':')) then (
243247
substring-after($function-name, ":") || "." || $arity
244248
) else (
245249
$function-name || $arity
246250
)
247251
let $description := $comment/xqdoc:description/node()
248-
let $parsed :=
252+
let $parsed :=
249253
if (contains($description, '&lt;') or contains($description, '&amp;')) then (
250-
$description
254+
$description
251255
) else (
252-
let $constructed-xml := "<div>" || replace($description, "\n{2,}", "<br/>") || "</div>"
256+
let $constructed-xml := "<div>" || replace($description, "\n{2,}", "<br/>") || "</div>"
253257
return parse-xml($constructed-xml)/*/node()
254258
)
255259
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
408412
()
409413
};
410414

411-
declare
415+
declare
412416
%templates:default("w3c", "false")
413417
%templates:default("extensions", "false")
414418
%templates:default("appmodules", "false")
@@ -420,16 +424,16 @@ function app:showmodules(
420424
let $uri := $module/xqdoc:module/xqdoc:uri
421425
let $location := $module/xqdoc:control/xqdoc:location
422426
order by $uri
423-
return
424-
if (
425-
($w3c and starts-with($uri, 'http://www.w3.org')) or
427+
return
428+
if (
429+
($w3c and starts-with($uri, 'http://www.w3.org')) or
426430
($appmodules and starts-with($location, '/db')) or
427431
($extensions and app:is-extension($uri, $location))
428432
) then (
429433
<tr>
430434
<td><a href="view?uri={$uri}&amp;location={$location}#">{$uri}</a></td>
431435
<td>{$location}</td>
432-
</tr>
436+
</tr>
433437
) else ()
434438
};
435439

@@ -440,7 +444,7 @@ declare function app:is-extension($uri as xs:string, $location as xs:string?) as
440444
(starts-with($uri, 'http://exquery.org/ns/') and (empty($location) or starts-with($location, 'java:')))
441445
};
442446

443-
declare
447+
declare
444448
%templates:default("uri", "http://www.w3.org/2005/xpath-functions")
445449
%templates:default("details", "false")
446450
function app:view(
@@ -464,7 +468,7 @@ function app:view(
464468
if (empty($function)) then (
465469
app:print-module($module, $module//xqdoc:function, $details cast as xs:boolean)
466470
) else (
467-
let $functions :=
471+
let $functions :=
468472
if (exists($arity)) then (
469473
$module//xqdoc:function[xqdoc:name eq $function][count(xqdoc:comment/xqdoc:param) = $arity]
470474
) else (

xar-assembly.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
<prepare>prepare.xq</prepare>
1919
<finish>finish.xq</finish>
2020
<changelog>
21+
<change version="2.0.2-SNAPSHOT">
22+
<ul xmlns="http://www.w3.org/1999/xhtml">
23+
<li>Improve search, looking at parameters and return's comments - <a href="https://github.com/eXist-db/function-documentation/pull/130">#130</a></li>
24+
</ul>
25+
</change>
2126
<change version="2.0.1">
2227
<ul xmlns="http://www.w3.org/1999/xhtml">
2328
<li>Fix an edge case in legacy URL handling - <a href="https://github.com/eXist-db/function-documentation/pull/123">#123</a></li>

0 commit comments

Comments
 (0)