xref: /linux-6.15/scripts/split-man.pl (revision c25ce589)
1*c25ce589SFinn Behrens#!/usr/bin/env perl
25b229fbeSMatthew Wilcox# SPDX-License-Identifier: GPL-2.0
35b229fbeSMatthew Wilcox#
432590819SMauro Carvalho Chehab# Author: Mauro Carvalho Chehab <[email protected]>
55b229fbeSMatthew Wilcox#
65b229fbeSMatthew Wilcox# Produce manpages from kernel-doc.
75b229fbeSMatthew Wilcox# See Documentation/doc-guide/kernel-doc.rst for instructions
85b229fbeSMatthew Wilcox
95b229fbeSMatthew Wilcoxif ($#ARGV < 0) {
105b229fbeSMatthew Wilcox   die "where do I put the results?\n";
115b229fbeSMatthew Wilcox}
125b229fbeSMatthew Wilcox
135b229fbeSMatthew Wilcoxmkdir $ARGV[0],0777;
145b229fbeSMatthew Wilcox$state = 0;
155b229fbeSMatthew Wilcoxwhile (<STDIN>) {
165b229fbeSMatthew Wilcox    if (/^\.TH \"[^\"]*\" 9 \"([^\"]*)\"/) {
175b229fbeSMatthew Wilcox	if ($state == 1) { close OUT }
185b229fbeSMatthew Wilcox	$state = 1;
195b229fbeSMatthew Wilcox	$fn = "$ARGV[0]/$1.9";
205b229fbeSMatthew Wilcox	print STDERR "Creating $fn\n";
215b229fbeSMatthew Wilcox	open OUT, ">$fn" or die "can't open $fn: $!\n";
225b229fbeSMatthew Wilcox	print OUT $_;
235b229fbeSMatthew Wilcox    } elsif ($state != 0) {
245b229fbeSMatthew Wilcox	print OUT $_;
255b229fbeSMatthew Wilcox    }
265b229fbeSMatthew Wilcox}
275b229fbeSMatthew Wilcox
285b229fbeSMatthew Wilcoxclose OUT;
29