aboutsummaryrefslogtreecommitdiffstats
#!/bin/bash

tree -J ../theories -P "*.v" | jq --arg "current" "$1" -r '
	("../" * ($current | [ scan("/+") ] | length)) as $prefix |
	def make_item_link(prefix):
		(if $current == prefix + .name then " class=\"current\"" else "" end) as $extra |
		"<a href=\"\($prefix)\(prefix)\(.name | @uri).html\"\($extra)>\(.name | @html)</a>";
	def handle_item(prefix):
		if .type == "directory" then
			"<li>\(.name | @html)<ul>" +
			(.name as $dir | .contents | map(handle_item("\(prefix)\($dir)/")) | add) +
			"</ul></li>"
		else
			"<li>\(make_item_link(prefix))</li>"
		end;
	.[0].contents | map(handle_item("")) | add
'