From 751112d9a980c98591ddd097e6bcf146edb42be3 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 15 Apr 2020 16:43:07 +0100 Subject: Rename mkversions to mkdescriptions. --- tools/mkdescriptions | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/mkheaders | 1 + tools/mkversions | 87 ---------------------------------------------------- 3 files changed, 88 insertions(+), 87 deletions(-) create mode 100755 tools/mkdescriptions delete mode 100755 tools/mkversions (limited to 'tools') diff --git a/tools/mkdescriptions b/tools/mkdescriptions new file mode 100755 index 000000000..ee29f48e9 --- /dev/null +++ b/tools/mkdescriptions @@ -0,0 +1,87 @@ +#!/usr/bin/env perl +# +# InspIRCd -- Internet Relay Chat Daemon +# +# Copyright (C) 2020 Sadie Powell +# +# This file is part of InspIRCd. InspIRCd is free software: you can +# redistribute it and/or modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation, version 2. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +BEGIN { + require 5.10.0; + unless (-f 'configure') { + print "Error: $0 must be run from the main source directory!\n"; + exit 1; + } +} + +use feature ':5.10'; +use strict; +use warnings FATAL => qw(all); + +use File::Basename qw(basename dirname); +use File::Spec::Functions qw(catdir catfile rel2abs); +use FindBin qw($RealDir); +use HTML::FormatText (); +use HTML::TreeBuilder (); +use Text::Markdown::Hoedown qw(HOEDOWN_HTML_SKIP_HTML markdown); +use Text::Sentence qw(split_sentences); + +use lib dirname $RealDir; +use make::common; +use make::console; + +if (scalar @ARGV < 1) { + print_format "<|GREEN Usage:|> $0 <<|UNDERLINE DOCS-SITE|>>\n", *STDERR; + exit 1; +} + +my %version = get_version(); +my $docdir = rel2abs catdir $ARGV[0], 'docs', $version{MAJOR}, 'modules'; +print_error "unable to find the module directory at $docdir!" unless -d $docdir; + +for my $module (, , ) { + print_error "unable to extract module name from $module!" unless $module =~ /m_(\w+)[.\/]/; + my $docfile = catfile $docdir, "$1.md"; + print_error "unable to find the module documentation at $docfile!" unless -f $docfile; + + open(my $dh, $docfile) or print_error "unable to read from $docfile: $!"; + my $docdata = do { local $/; <$dh> }; + close $dh; + print_error "unable to find the module description in $docfile!" unless $docdata =~ /\#\#\# Description\n\n(?:This module )?([^\n]+)/; + + my $docrendered = markdown ucfirst $1, extensions => HOEDOWN_HTML_SKIP_HTML; + my $docplain = HTML::FormatText->new(leftmargin => 0, rightmargin => ~0)->format(HTML::TreeBuilder->new->parse($docrendered)); + + my $description = (split_sentences $docplain)[0] =~ s/"/\\"/gr; + chomp($description); + + open(my $mih, $module) or print_error "unable to read from $module: $!"; + my @lines; + for my $line (<$mih>) { + chomp $line; + if ($line =~ /(\t+return Version\(")[^"]+(",.+)/) { + push @lines, join '', $1, $description, $2; + } else { + push @lines, $line; + } + } + close $mih; + + open(my $moh, '>', $module) or print_error "unable to write to $module: $!"; + for my $line (@lines) { + say $moh $line; + } + close $moh; +} diff --git a/tools/mkheaders b/tools/mkheaders index ee8142d3b..8367b94a1 100755 --- a/tools/mkheaders +++ b/tools/mkheaders @@ -43,6 +43,7 @@ use make::console; my @ignored_revisions = ( '0b4285abd12323920d92fee51e199edd7527dbec', # adding copyright headers '46a39046196f55b52336e19662bb7bac85b731ac', # adding copyright headers + '4a6fedd9324d87349a806c9c1d0ae6e7d3c1fd38', # mass-updating descriptions '56375392ba94f2552bbeeeab4fd39e1e50295525', # sadie's name change 'bab14f0dd2345c9d7dcbc47c918563709e1ac094', # peavey breaking line endings 'f2acdbc3820f0f4f5ef76a0a64e73d2a320df91f', # peavey fixing line endings diff --git a/tools/mkversions b/tools/mkversions deleted file mode 100755 index ee29f48e9..000000000 --- a/tools/mkversions +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env perl -# -# InspIRCd -- Internet Relay Chat Daemon -# -# Copyright (C) 2020 Sadie Powell -# -# This file is part of InspIRCd. InspIRCd is free software: you can -# redistribute it and/or modify it under the terms of the GNU General Public -# License as published by the Free Software Foundation, version 2. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - - -BEGIN { - require 5.10.0; - unless (-f 'configure') { - print "Error: $0 must be run from the main source directory!\n"; - exit 1; - } -} - -use feature ':5.10'; -use strict; -use warnings FATAL => qw(all); - -use File::Basename qw(basename dirname); -use File::Spec::Functions qw(catdir catfile rel2abs); -use FindBin qw($RealDir); -use HTML::FormatText (); -use HTML::TreeBuilder (); -use Text::Markdown::Hoedown qw(HOEDOWN_HTML_SKIP_HTML markdown); -use Text::Sentence qw(split_sentences); - -use lib dirname $RealDir; -use make::common; -use make::console; - -if (scalar @ARGV < 1) { - print_format "<|GREEN Usage:|> $0 <<|UNDERLINE DOCS-SITE|>>\n", *STDERR; - exit 1; -} - -my %version = get_version(); -my $docdir = rel2abs catdir $ARGV[0], 'docs', $version{MAJOR}, 'modules'; -print_error "unable to find the module directory at $docdir!" unless -d $docdir; - -for my $module (, , ) { - print_error "unable to extract module name from $module!" unless $module =~ /m_(\w+)[.\/]/; - my $docfile = catfile $docdir, "$1.md"; - print_error "unable to find the module documentation at $docfile!" unless -f $docfile; - - open(my $dh, $docfile) or print_error "unable to read from $docfile: $!"; - my $docdata = do { local $/; <$dh> }; - close $dh; - print_error "unable to find the module description in $docfile!" unless $docdata =~ /\#\#\# Description\n\n(?:This module )?([^\n]+)/; - - my $docrendered = markdown ucfirst $1, extensions => HOEDOWN_HTML_SKIP_HTML; - my $docplain = HTML::FormatText->new(leftmargin => 0, rightmargin => ~0)->format(HTML::TreeBuilder->new->parse($docrendered)); - - my $description = (split_sentences $docplain)[0] =~ s/"/\\"/gr; - chomp($description); - - open(my $mih, $module) or print_error "unable to read from $module: $!"; - my @lines; - for my $line (<$mih>) { - chomp $line; - if ($line =~ /(\t+return Version\(")[^"]+(",.+)/) { - push @lines, join '', $1, $description, $2; - } else { - push @lines, $line; - } - } - close $mih; - - open(my $moh, '>', $module) or print_error "unable to write to $module: $!"; - for my $line (@lines) { - say $moh $line; - } - close $moh; -} -- cgit v1.2.3