mirror of
https://github.com/wader/fq.git
synced 2024-11-29 04:10:01 +03:00
f4480c6fe5
interp: Refactor format help and also include options interp: Add -o name=@path to load file content as value (not documented yet, might change) interp,decode: Expose decode out value as _out (might change) interp: Refactor foramts.jq into format_{decode,func,include}.jq interp: Refactor torepr into _format_func for generic format function overloading interp: Refactor -o options parsing to be more generic and collect unknowns options to be used as format options decode of decode alises func for format overloaded functions include for format specific jq functions (also _help, torepr etc) flac_frame: Add bits_per_sample option mp3: Add max_unique_header_config and max_sync_seek options mp4: Add decode_samples and allow_truncate options avc_au: Has length_size option hevc_au: Has length_size option aac_frame: Has object_typee option doc: Rewrite format doc generation, less hack more jq
150 lines
3.5 KiB
Plaintext
Executable File
150 lines
3.5 KiB
Plaintext
Executable File
#!/usr/bin/env fq -rnf
|
|
|
|
def code: "`\(.)`";
|
|
def nbsp: gsub(" "; " ");
|
|
def has_section($f; $fhelp): $fhelp.notes or $fhelp.examples or $fhelp.links or $f.decode_in_arg;
|
|
|
|
def formats_list:
|
|
[ formats
|
|
| to_entries[] as {$key, $value}
|
|
| (_format_func($key; "_help")? // {}) as $fhelp
|
|
| if has_section($value; $fhelp) then "[\($key)](doc/formats.md#\($key))"
|
|
else $key
|
|
end
|
|
] | join(",\n");
|
|
|
|
def formats_table:
|
|
( [ {
|
|
name: "Name",
|
|
desc: "Description",
|
|
uses: "Dependencies"
|
|
},
|
|
{
|
|
name: "-",
|
|
desc: "-",
|
|
uses: "-"
|
|
},
|
|
( formats
|
|
| to_entries[]
|
|
| (_format_func(.key; "_help")? // {}) as $fhelp
|
|
| {
|
|
name:
|
|
( ( .key as $format
|
|
| if has_section(.value; $fhelp) then "[\($format | code)](#\($format))"
|
|
else $format | code
|
|
end
|
|
)
|
|
+ " "
|
|
),
|
|
desc: (.value.description | nbsp),
|
|
uses: "<sub>\((((.value.dependencies | flatten | map(code)) | join(" "))? // ""))</sub>"
|
|
}
|
|
),
|
|
( [ formats
|
|
| to_entries[]
|
|
| . as $e
|
|
| select(.value.groups)
|
|
| .value.groups[] | {key: ., value: $e.key}
|
|
]
|
|
| reduce .[] as $e ({}; .[$e.key] += [$e.value])
|
|
| to_entries[]
|
|
| {
|
|
name: ((.key | code) + " "),
|
|
desc: "Group",
|
|
uses: "<sub>\(((.value | map(code)) | join(" ")))</sub>"
|
|
}
|
|
)
|
|
]
|
|
| table(
|
|
[ .name
|
|
, .desc
|
|
, .uses
|
|
];
|
|
[ ""
|
|
, (.[0] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
|
|
, (.[1] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
|
|
, .[2].string
|
|
, ""
|
|
] | join("|")
|
|
)
|
|
);
|
|
|
|
def formats_sections:
|
|
( formats[] as $f
|
|
| (_format_func($f.name; "_help")? // {} | _help_format_enrich("fq"; $f; false)) as $fhelp
|
|
| select(has_section($f; $fhelp))
|
|
| "### \($f.name)"
|
|
, ""
|
|
, ($fhelp.notes | if . then ., "" else empty end)
|
|
, if $f.decode_in_arg then
|
|
( "#### Options"
|
|
, ""
|
|
, ( [ { name: "Name"
|
|
, default: "Default"
|
|
, desc: "Description"
|
|
}
|
|
, { name: "-"
|
|
, default: "-"
|
|
, desc: "-"
|
|
}
|
|
, ( $f.decode_in_arg
|
|
| to_entries[] as {$key,$value}
|
|
| { name: ($key | code)
|
|
, default: ($value | tostring)
|
|
, desc: $f.decode_in_arg_doc[$key]
|
|
}
|
|
)
|
|
]
|
|
| table(
|
|
[ .name
|
|
, .default
|
|
, .desc
|
|
];
|
|
[ ""
|
|
, (.[0] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
|
|
, (.[1] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
|
|
, .[2].string
|
|
, ""
|
|
] | join("|")
|
|
)
|
|
)
|
|
, ""
|
|
)
|
|
else empty
|
|
end
|
|
, if $fhelp.examples then
|
|
( "#### Examples"
|
|
, ""
|
|
, ( $fhelp.examples[]
|
|
| "\(.comment)"
|
|
, if .shell then
|
|
( "```"
|
|
, "$ \(.shell)"
|
|
, "```"
|
|
)
|
|
elif .expr then
|
|
( "```"
|
|
, "... | \(.expr)"
|
|
, "```"
|
|
)
|
|
else empty
|
|
end
|
|
, ""
|
|
)
|
|
)
|
|
else empty
|
|
end
|
|
, if $fhelp.links then
|
|
( "#### References and links"
|
|
, ""
|
|
, ( $fhelp.links[]
|
|
| if .title then "- [\(.title)](\(.url))"
|
|
else "- \(.url)"
|
|
end
|
|
)
|
|
, ""
|
|
)
|
|
else empty
|
|
end
|
|
);
|