Small improvements

This commit is contained in:
Clément Fournier
2018-05-24 17:58:54 +02:00
parent ae8a26c22d
commit eb21f3189d
3 changed files with 21 additions and 21 deletions

View File

@ -28,6 +28,24 @@ module CustomFilters
any
end
# sorts an array using the order defined by the given sidebar
def sort_using(xs, sidebar)
# caching is possible but doesn't improve significantly the build times
rank_lookup = rank_lookup_from_sidebar(sidebar)
xs.sort {|x, y|
# The default rank is very high so that pages that don't appear in the sidebar are put at the end
rx = rank_lookup[x.url] || 10000
ry = rank_lookup[y.url] || 10000
rx <=> ry
}
end
private
def flatten_rec(seq)
seq.map {|h|
if (subs = h["folderitems"] || h["subfolderitems"] || h["subfolders"])
@ -50,24 +68,6 @@ module CustomFilters
end
# sorts an array using the order defined by the given sidebar
def sort_using(xs, sidebar)
# caching is possible but doesn't improve significantly the build times
rank_lookup = rank_lookup_from_sidebar(sidebar)
xs.sort {|x, y|
# The default rank is very high so that pages that don't appear in the sidebar are put at the end
rx = rank_lookup[x.url] || 10000
ry = rank_lookup[y.url] || 10000
rx <=> ry
}
end
end
Liquid::Template.register_filter(CustomFilters)

View File

@ -44,13 +44,13 @@ The tool comes with a rather extensive help text, simply running with `-help`!
specified.
</td>
<td>no</td>
<td></td>
<td>Java</td>
</tr>
<tr>
<td>-uri / -u</td>
<td>Database URI for sources. If this is given, then you don't need to provide `-dir`.</td>
<td>no</td>
<td>plsql</td>
<td>PLSQL</td>
</tr>
<tr>
<td>-filelist</td>

View File

@ -42,7 +42,7 @@ The PMD command (`pmd.bat` or `run.sh pmd`) requires two options:
sources.
* `-R <path>`: the ruleset file you want to use. PMD uses xml configuration files, called *rulesets*, which specify
which rules to execute on your sources. You can also run a single rule by referencing it using its *category* and
name (more details [here](pmd_userdocs_making_rulesets.html#referencing-rules)). For example, you can check for unnecessary
name (more details [here](pmd_userdocs_making_rulesets.html#referencing-a-single-rule)). For example, you can check for unnecessary
modifiers on Java sources with `-R category/java/codestyle.xml/UnnecessaryModifier`.
{% include note.html