* docbook2mdoc: provide an -s command line option to override the section
@ 2019-05-01 9:02 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-05-01 9:02 UTC (permalink / raw)
To: source
Log Message:
-----------
provide an -s command line option to override the section in .Dt
Modified Files:
--------------
docbook2mdoc:
docbook2mdoc.1
main.c
reorg.c
reorg.h
Revision Data
-------------
Index: reorg.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/reorg.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lreorg.c -Lreorg.c -u -p -r1.4 -r1.5
--- reorg.c
+++ reorg.c
@@ -24,7 +24,7 @@
*/
static void
-reorg_root(struct pnode *root)
+reorg_root(struct pnode *root, const char *sec)
{
struct pnode *date, *info, *name, *vol, *nc;
@@ -53,11 +53,12 @@ reorg_root(struct pnode *root)
pnode_alloc_text(name,
pnode_getattr_raw(root, ATTRKEY_ID, "UNKNOWN"));
}
- if (vol == NULL) {
+ if (vol == NULL || sec != NULL) {
+ pnode_unlink(vol);
vol = pnode_alloc(NULL);
vol->node = NODE_MANVOLNUM;
vol->parent = root;
- pnode_alloc_text(vol, "1");
+ pnode_alloc_text(vol, sec == NULL ? "1" : sec);
}
/* Insert prologue information at the beginning. */
@@ -271,8 +272,8 @@ reorg_recurse(struct pnode *n)
}
void
-ptree_reorg(struct ptree *tree)
+ptree_reorg(struct ptree *tree, const char *sec)
{
- reorg_root(tree->root);
+ reorg_root(tree->root, sec);
reorg_recurse(tree->root);
}
Index: docbook2mdoc.1
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.1,v
retrieving revision 1.14
retrieving revision 1.15
diff -Ldocbook2mdoc.1 -Ldocbook2mdoc.1 -u -p -r1.14 -r1.15
--- docbook2mdoc.1
+++ docbook2mdoc.1
@@ -24,6 +24,7 @@
.Sh SYNOPSIS
.Nm docbook2mdoc
.Op Fl W
+.Op Fl s Ar section
.Op Fl T Cm mdoc | tree | lint
.Op Ar file
.Sh DESCRIPTION
@@ -43,6 +44,19 @@ or omitted, standard input is used.
.Pp
The options are as follows:
.Bl -tag -width 2n
+.It Fl s
+Specify the manual page
+.Ar section
+to be used as the second argument of the
+.Ic \&Dt
+macro.
+Defaults to the content of the first
+.Eo < Ic manvolnum Ec >
+element in the first
+.Eo < Ic refmeta Ec >
+block, if any, or to
+.Qq 1
+otherwise.
.It Fl T
Select the output mode.
The following arguments are supported:
Index: reorg.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/reorg.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lreorg.h -Lreorg.h -u -p -r1.1 -r1.2
--- reorg.h
+++ reorg.h
@@ -19,4 +19,4 @@
* The interface of the tree reorganizer.
*/
-void ptree_reorg(struct ptree *);
+void ptree_reorg(struct ptree *, const char *sec);
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/main.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lmain.c -Lmain.c -u -p -r1.9 -r1.10
--- main.c
+++ main.c
@@ -42,7 +42,7 @@ main(int argc, char *argv[])
struct parse *parser;
struct ptree *tree;
const char *progname;
- const char *fname, *bname;
+ const char *bname, *fname, *sec;
int ch, fd, rc, warn;
enum outt outtype;
@@ -51,10 +51,14 @@ main(int argc, char *argv[])
else
progname++;
+ sec = NULL;
warn = 0;
outtype = OUTT_MDOC;
- while ((ch = getopt(argc, argv, "T:W")) != -1) {
+ while ((ch = getopt(argc, argv, "s:T:W")) != -1) {
switch (ch) {
+ case 's':
+ sec = optarg;
+ break;
case 'T':
if (strcmp(optarg, "mdoc") == 0)
outtype = OUTT_MDOC;
@@ -98,7 +102,7 @@ main(int argc, char *argv[])
parser = parse_alloc(warn);
tree = parse_file(parser, fd, fname);
- ptree_reorg(tree);
+ ptree_reorg(tree, sec);
rc = tree->flags & TREE_ERROR ? 3 : tree->flags & TREE_WARN ? 2 : 0;
/* Format. */
@@ -121,7 +125,7 @@ main(int argc, char *argv[])
return rc;
usage:
- fprintf(stderr, "usage: %s [-W] [-T mdoc | tree | lint] "
- "[input_filename]\n", progname);
+ fprintf(stderr, "usage: %s [-W] [-s section] "
+ "[-T mdoc | tree | lint] [input_filename]\n", progname);
return 5;
}
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-05-01 9:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 9:02 docbook2mdoc: provide an -s command line option to override the section schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).