2022-10-11 15:34:38 +08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2023-01-02 20:51:48 +08:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2022-10-11 15:34:38 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
|
|
|
#
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: curl
|
|
|
|
#
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
my $root=$ARGV[0] || "..";
|
|
|
|
|
|
|
|
my @m = `git ls-files -- $root`;
|
|
|
|
|
|
|
|
my $errors;
|
|
|
|
|
|
|
|
my %accepted=('curl' => 1,
|
2024-01-17 18:32:44 +08:00
|
|
|
'libcurl' => 1,
|
2024-03-15 16:38:21 +08:00
|
|
|
'macOS' => 1,
|
2024-08-16 17:45:26 +08:00
|
|
|
'wolfSSL' => 1,
|
2024-03-13 08:21:06 +08:00
|
|
|
'mbedTLS' => 1,
|
2024-08-16 17:45:26 +08:00
|
|
|
'rustls' => 1,
|
2024-01-17 18:32:44 +08:00
|
|
|
'c-ares' => 1);
|
2022-10-11 15:34:38 +08:00
|
|
|
|
|
|
|
sub checkfile {
|
|
|
|
my ($f) = @_;
|
|
|
|
chomp $f;
|
|
|
|
if($f !~ /\.md\z/) {
|
|
|
|
return;
|
|
|
|
}
|
2023-03-29 04:29:36 +08:00
|
|
|
open(my $fh, "<", "$f");
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $l;
|
2022-10-11 15:34:38 +08:00
|
|
|
my $prevl;
|
2022-10-14 14:55:37 +08:00
|
|
|
my $ignore = 0;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $metadata = 0;
|
2023-03-29 04:29:36 +08:00
|
|
|
while(<$fh>) {
|
2022-10-11 15:34:38 +08:00
|
|
|
my $line = $_;
|
|
|
|
chomp $line;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$l++;
|
|
|
|
if(($l == 1) && ($line =~ /^---/)) {
|
|
|
|
# first line is a meta-data divider, skip to the next one
|
|
|
|
$metadata = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif($metadata) {
|
|
|
|
if($line !~ /^---/) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
$metadata = 0;
|
|
|
|
next;
|
|
|
|
}
|
2022-10-14 14:55:37 +08:00
|
|
|
if($line =~ /^(\`\`\`|\~\~\~)/) {
|
|
|
|
# start or stop ignore-mode
|
|
|
|
$ignore ^= 1;
|
2022-10-11 15:34:38 +08:00
|
|
|
}
|
2022-10-14 14:55:37 +08:00
|
|
|
if(!$ignore) {
|
2024-03-15 16:38:21 +08:00
|
|
|
if(($prevl =~ /\.\z/) && ($line =~ /^( *)([a-z][A-Za-z-]*)/)) {
|
2022-10-14 14:55:37 +08:00
|
|
|
my ($prefix, $word) = ($1, $2);
|
2024-01-17 18:32:44 +08:00
|
|
|
if($word =~ /^[a-z]/ && !$accepted{$word}) {
|
2022-10-14 14:55:37 +08:00
|
|
|
my $c = length($prefix);
|
|
|
|
print STDERR
|
|
|
|
"$f:$l:$c:error: lowercase $word after period\n";
|
|
|
|
print STDERR "$line\n";
|
|
|
|
print STDERR ' ' x $c;
|
|
|
|
print STDERR "^\n";
|
|
|
|
$errors++;
|
|
|
|
}
|
2022-10-11 15:34:38 +08:00
|
|
|
}
|
2024-01-17 18:32:44 +08:00
|
|
|
elsif($line =~ /^(.*)\. +([a-z-]+)/) {
|
2022-10-14 14:55:37 +08:00
|
|
|
my ($prefix, $word) = ($1, $2);
|
|
|
|
|
|
|
|
if(($prefix =~ /\.\.\z/) ||
|
|
|
|
($prefix =~ /[0-9]\z/) ||
|
|
|
|
($prefix =~ /e.g\z/) ||
|
|
|
|
($prefix =~ /i.e\z/) ||
|
2024-01-17 18:32:44 +08:00
|
|
|
($prefix =~ /E.g\z/) ||
|
2022-10-14 14:55:37 +08:00
|
|
|
($prefix =~ /etc\z/) ||
|
2024-01-17 18:32:44 +08:00
|
|
|
($word !~ /^[a-z]/) ||
|
2022-10-14 14:55:37 +08:00
|
|
|
$accepted{$word}) {
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $c = length($prefix) + 2;
|
|
|
|
print STDERR
|
|
|
|
"$f:$l:$c:error: lowercase $word after period\n";
|
|
|
|
print STDERR "$line\n";
|
|
|
|
print STDERR ' ' x $c;
|
|
|
|
print STDERR "^\n";
|
|
|
|
$errors++;
|
|
|
|
}
|
2022-10-11 15:34:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$prevl = $line;
|
|
|
|
}
|
2023-03-29 04:29:36 +08:00
|
|
|
close($fh);
|
2022-10-11 15:34:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for my $f (@m) {
|
|
|
|
checkfile($f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($errors) {
|
|
|
|
exit 1;
|
|
|
|
}
|
2022-10-13 23:04:46 +08:00
|
|
|
print "ok\n";
|