Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb292256

Browse files
committed
Improve docs syntax checking
Move the checks out of the Makefile into a perl script that can becalled from both the Makefile and meson.build. The set of files checkedis simplified, so it is just all the sgml and xsl files found indocs/src/sgml directory tree.Along the way make some adjustments to .cirrus.tasks.yml to support thisbetter in CI.Also ensure that the checks are part of the Makefile's html target.Author: Nazir Bilal Yavuz <byavuz81@gmail.com>Co-Author: Andrew Dunstan <andrew@dunslane.net>Discussion:https://postgr.es/m/CAN55FZ3BnM+0twT-ZWL8As9oBEte_b+SBU==cz6Hk8JUCM_5Wg@mail.gmail.com
1 parent482bc07 commitb292256

File tree

4 files changed

+106
-15
lines changed

4 files changed

+106
-15
lines changed

‎.cirrus.tasks.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ task:
627627
TEST_JOBS:8
628628
IMAGE:ghcr.io/cirruslabs/macos-runner:sonoma
629629

630+
XML_CATALOG_FILES:/opt/local/share/xml/docbook/4.5/catalog.xml
631+
630632
CIRRUS_WORKING_DIR:${HOME}/pgsql/
631633
CCACHE_DIR:${HOME}/ccache
632634
MACPORTS_CACHE:${HOME}/macports-cache
@@ -641,6 +643,7 @@ task:
641643
642644
MACOS_PACKAGE_LIST:>-
643645
ccache
646+
docbook-xml-4.5
644647
icu
645648
kerberos5
646649
lz4

‎doc/src/sgml/Makefile‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ ifeq ($(STYLE),website)
124124
XSLTPROC_HTML_FLAGS += --param website.stylesheet 1
125125
endif
126126

127-
html: html-stamp
127+
html:checkhtml-stamp
128128

129129
html-stamp: stylesheet.xsl postgres-full.xml$(ALL_IMAGES)
130130
$(XSLTPROC)$(XMLINCLUDE)$(XSLTPROCFLAGS)$(XSLTPROC_HTML_FLAGS)$(wordlist 1,2,$^)
@@ -200,8 +200,8 @@ MAKEINFO = makeinfo
200200
##
201201

202202
# Quick syntax check without style processing
203-
check: postgres.sgml$(ALL_SGML) check-tabs check-nbsp
204-
$(XMLLINT)$(XMLINCLUDE) --noout --valid$<
203+
check: postgres.sgml$(ALL_SGML)
204+
$(PERL)$(srcdir)/sgml_syntax_check.pl --xmllint"$(XMLLINT)" --srcdir$(srcdir)
205205

206206

207207
##
@@ -261,18 +261,6 @@ clean-man:
261261

262262
endif# sqlmansectnum != 7
263263

264-
# tabs are harmless, but it is best to avoid them in SGML files
265-
check-tabs:
266-
@(! grep''$(wildcard$(srcdir)/*.sgml$(srcdir)/func/*.sgml$(srcdir)/ref/*.sgml$(srcdir)/*.xsl) )||\
267-
(echo"Tabs appear in SGML/XML files"1>&2;exit 1)
268-
269-
# Non-breaking spaces are harmless, but it is best to avoid them in SGML files.
270-
# Use perl command because non-GNU grep or sed could not have hex escape sequence.
271-
check-nbsp:
272-
@ ($(PERL) -ne'/\xC2\xA0/ and print("$$ARGV:$$_"),$$n++; END {exit($$n>0)}' \
273-
$(wildcard$(srcdir)/*.sgml$(srcdir)/func/*.sgml$(srcdir)/ref/*.sgml$(srcdir)/*.xsl$(srcdir)/images/*.xsl) )||\
274-
(echo"Non-breaking spaces appear in SGML/XML files"1>&2;exit 1)
275-
276264
##
277265
## Clean
278266
##

‎doc/src/sgml/meson.build‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,26 @@ endif
306306
if alldocs.length()!=0
307307
alias_target('alldocs', alldocs)
308308
endif
309+
310+
sgml_syntax_check=files(
311+
'sgml_syntax_check.pl'
312+
)
313+
314+
test(
315+
'sgml_syntax_check',
316+
perl,
317+
protocol:'exitcode',
318+
suite:'doc',
319+
args: [
320+
sgml_syntax_check,
321+
'--xmllint',
322+
'@0@ --nonet'.format(xmllint_bin.full_path()),
323+
'--srcdir',
324+
meson.current_source_dir(),
325+
'--builddir',
326+
meson.current_build_dir(),
327+
],
328+
depends: doc_generated
329+
)
330+
331+
testprep_targets+= doc_generated

‎doc/src/sgml/sgml_syntax_check.pl‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# /usr/bin/perl
2+
3+
# Copyright (c) 2025, PostgreSQL Global Development Group
4+
5+
# doc/src/sgml/sgml_syntax_check.pl
6+
7+
use strict;
8+
use warningsFATAL=>'all';
9+
use Getopt::Long;
10+
11+
use File::Find;
12+
13+
my$xmllint;
14+
my$srcdir;
15+
my$builddir;
16+
17+
GetOptions(
18+
'xmllint:s'=> \$xmllint,
19+
'srcdir:s'=> \$srcdir,
20+
'builddir:s'=> \$builddir)ordie"$0: wrong arguments";
21+
22+
die"$0: --srcdir must be specified\n"unlessdefined$srcdir;
23+
24+
my$xmlinclude ="--path . --path$srcdir";
25+
$xmlinclude .=" --path$builddir"ifdefined$builddir;
26+
27+
# find files to process - all the sgml and xsl files (including in subdirectories)
28+
my@files_to_process;
29+
my@dirs_to_search = ($srcdir);
30+
push@dirs_to_search,$builddirifdefined$builddir;
31+
find(
32+
sub {
33+
returnunless-f$_;
34+
returnif$_ !~/\.(sgml|xsl)$/;
35+
push@files_to_process,$File::Find::name;
36+
},
37+
@dirs_to_search,);
38+
39+
# tabs and non-breaking spaces are harmless, but it is best to avoid them in SGML files
40+
subcheck_tabs_and_nbsp
41+
{
42+
my$errors = 0;
43+
formy$f (@files_to_process)
44+
{
45+
openmy$fh,"<:encoding(UTF-8)",$fordie"Can't open$f:$!";
46+
my$line_no = 0;
47+
while (<$fh>)
48+
{
49+
$line_no++;
50+
if (/\t/)
51+
{
52+
printSTDERR"Tab found in$f:$line_no\n";
53+
$errors++;
54+
}
55+
if (/\xC2\xA0/)
56+
{
57+
printSTDERR"$f:$line_no: contains non-breaking space\n";
58+
$errors++;
59+
}
60+
}
61+
close($fh);
62+
}
63+
64+
if ($errors)
65+
{
66+
die"Tabs and/or non-breaking spaces appear in SGML/XML files\n";
67+
}
68+
}
69+
70+
subrun_xmllint
71+
{
72+
my$cmd ="$xmllint$xmlinclude --noout --valid postgres.sgml";
73+
system($cmd) == 0ordie"xmllint validation failed\n";
74+
}
75+
76+
run_xmllint();
77+
check_tabs_and_nbsp();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp