{
const char *cmd; /* the command name */
const char *help; /* the help associated with it */
+ const char *docbook_id; /* DocBook XML id (for generating URL) */
void (*syntaxfunc)(PQExpBuffer); /* function that prints the syntax associated with it */
int nl_count; /* number of newlines in syntax (for pager) */
};
foreach my $file (sort readdir DIR)
{
- my (@cmdnames, $cmddesc, $cmdsynopsis);
+ my ($cmdid, @cmdnames, $cmddesc, $cmdsynopsis);
$file =~ /\.sgml$/ or next;
open(my $fh, '<', "$docdir/$file") or next;
m!<refmiscinfo>\s*SQL - Language Statements\s*</refmiscinfo>!i
or next;
+ $filecontent =~ m!<refentry id="([a-z-]+)">!
+ and $cmdid = $1;
+
# Collect multiple refnames
LOOP:
{
$filecontent =~ m!<synopsis>\s*(.+?)\s*</synopsis>!is
and $cmdsynopsis = $1;
- if (@cmdnames && $cmddesc && $cmdsynopsis)
+ if (@cmdnames && $cmddesc && $cmdid && $cmdsynopsis)
{
s/\"/\\"/g foreach @cmdnames;
foreach my $cmdname (@cmdnames)
{
$entries{$cmdname} = {
+ cmdid => $cmdid,
cmddesc => $cmddesc,
cmdsynopsis => $cmdsynopsis,
params => \@params,
$id =~ s/ /_/g;
print $cfile_handle " { \"$_\",
N_(\"$entries{$_}{cmddesc}\"),
+ \"$entries{$_}{cmdid}\",
sql_help_$id,
$entries{$_}{nl_count} },
strcmp(topic, "*") == 0)
{
PQExpBufferData buffer;
+ char *url;
initPQExpBuffer(&buffer);
QL_HELP[i].syntaxfunc(&buffer);
help_found = true;
+ url = psprintf("https://www.postgresql.org/docs/%s/%s.html",
+ strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,
+ QL_HELP[i].docbook_id);
fprintf(output, _("Command: %s\n"
"Description: %s\n"
- "Syntax:\n%s\n\n"),
+ "Syntax:\n%s\n\n"
+ "URL: %s\n\n"),
QL_HELP[i].cmd,
_(QL_HELP[i].help),
- buffer.data);
+ buffer.data,
+ url);
+ free(url);
/* If we have an exact match, exit. Fixes \h SELECT */
if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
break;