From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s32A6Fux030062 for ; Wed, 2 Apr 2014 06:06:15 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s32A6FpF019504; Wed, 2 Apr 2014 06:06:15 -0400 (EDT) Date: Wed, 2 Apr 2014 06:06:15 -0400 (EDT) Message-Id: <201404021006.s32A6FpF019504@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: docbook2mdoc: Add and a README for adding new nodes. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Add and a README for adding new nodes. Modified Files: -------------- docbook2mdoc: docbook2mdoc.c extern.h rules.c Added Files: ----------- docbook2mdoc: README Revision Data ------------- Index: extern.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/docbook2mdoc/extern.h,v retrieving revision 1.13 retrieving revision 1.14 diff -Lextern.h -Lextern.h -u -p -r1.13 -r1.14 --- extern.h +++ extern.h @@ -8,6 +8,7 @@ enum nodeid { NODE_ROOT = 0, /* Must comes first. */ /* Alpha-ordered hereafter. */ NODE_ACRONYM, + NODE_APPLICATION, NODE_ARG, NODE_CITEREFENTRY, NODE_CMDSYNOPSIS, Index: docbook2mdoc.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.26 retrieving revision 1.27 diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.26 -r1.27 --- docbook2mdoc.c +++ docbook2mdoc.c @@ -88,6 +88,7 @@ static const char *attrvals[ATTRVAL__MAX static const struct node nodes[NODE__MAX] = { { NULL, 0 }, { "acronym", 0 }, + { "application", 0 }, { "arg", 0 }, { "citerefentry", NODE_IGNTEXT }, { "cmdsynopsis", NODE_IGNTEXT }, @@ -1028,6 +1029,10 @@ pnode_print(struct parse *p, struct pnod sv = p->newln; switch (pn->node) { + case (NODE_APPLICATION): + pnode_printmopen(p); + fputs("Nm", stdout); + break; case (NODE_ARG): pnode_printarg(p, pn); pnode_unlinksub(pn); @@ -1229,6 +1234,7 @@ pnode_print(struct parse *p, struct pnod pnode_print(p, pp); switch (pn->node) { + case (NODE_APPLICATION): case (NODE_ARG): case (NODE_CODE): case (NODE_COMMAND): Index: rules.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/docbook2mdoc/rules.c,v retrieving revision 1.13 retrieving revision 1.14 diff -Lrules.c -Lrules.c -u -p -r1.13 -r1.14 --- rules.c +++ rules.c @@ -86,6 +86,29 @@ isparent(enum nodeid node, enum nodeid p break; } return(0); + case (NODE_APPLICATION): + switch (parent) { + case (NODE_EMPHASIS): + case (NODE_ENTRY): + case (NODE_FUNCSYNOPSISINFO): + case (NODE_LINK): + case (NODE_PARA): + case (NODE_PROGRAMLISTING): + case (NODE_REFCLASS): + case (NODE_REFDESCRIPTOR): + case (NODE_REFENTRYTITLE): + case (NODE_REFNAME): + case (NODE_REFPURPOSE): + case (NODE_SCREEN): + case (NODE_SYNOPSIS): + case (NODE_TERM): + case (NODE_TITLE): + case (NODE_ULINK): + return(1); + default: + break; + } + return(0); case (NODE_ARG): switch (parent) { case (NODE_ARG): @@ -348,6 +371,7 @@ isparent(enum nodeid node, enum nodeid p case (NODE_ULINK): /* Synonyms. */ switch (parent) { case (NODE_ACRONYM): + case (NODE_APPLICATION): case (NODE_ARG): case (NODE_CODE): case (NODE_COMMAND): @@ -588,6 +612,7 @@ isparent(enum nodeid node, enum nodeid p case (NODE_REPLACEABLE): switch (parent) { case (NODE_ACRONYM): + case (NODE_APPLICATION): case (NODE_ARG): case (NODE_CODE): case (NODE_COMMAND): --- /dev/null +++ README @@ -0,0 +1,35 @@ +$Id: README,v 1.1 2014/04/02 10:06:14 kristaps Exp $ + +Here's a quick note on how to add new DocBook elements. + +First, look up the element in the DocBook reference. For element , this is usually: + +http://docbook.org/tdg51/en/html/foo.html + +Add the alpha-ordered node (NODE_FOO) to extern.h. + +Next, add rules.c isparent() rule. This is the hard part. First, +create a top-level switch statement for NODE_FOO. Create a white-list +of switch cases beneath that corresponding to each "These elements +contain foo": + + switch (parent) { + case (NODE_BAR): + case (NODE_BAZ): + return(1); + default: + break; + } + return(0); + +Next, go through the "The following elements occur in foo" and add a +"case (NODE_FOO)" to each of those elements' switches. + +Now the hard work is finished! + +Next, add the name and whether it admits text to docbook2mdoc.c's +"nodes" structure array. + +Finally, modify print_pnode() with your new entry. Use similar nodes as +a reference. (NOTE: if it's an inline like, say, NODE_EMPHASIS, then +remember to add the node to the postfix switch statement!) -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv