source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: Add <application> and a README for adding new nodes.
@ 2014-04-02 10:06 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2014-04-02 10:06 UTC (permalink / raw)
  To: source

Log Message:
-----------
Add <application> 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 <foo>, 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-02 10:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-02 10:06 docbook2mdoc: Add <application> and a README for adding new nodes kristaps

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).