Repository navigation
Closed
Description
Following the discussion in #108. Supersedes #107, #108, #109, #110. I also added languages that provide these kinds of constructs (among those that I have used enough to have an opinion on how libraries could be documented), sometimes with a slight discussion; also, always with a DocBook equivalent when it makes sense (large parts have been mostly copy-pasted ).
New Element Definitions
The following elements have been added to support needs arising in code documentation:
- namespace: a container for a name space with modifiers in a programming language. Similar to
ooclass.- namespacename: the name of a name space. For instance, implemented in C++, Java, C#, XML. Similar to
classname.- namespacesynopsis: a container for a name space and its contents (which can be recursive). For instance, implemented in C++, Java, C#. Similar to
classsynopsis.- namespacesynopsisinfo: information supplementing the contents of a
namespacesynopsis. Similar toclasssynopsisinfo.- macro: the name of a macro. For instance, implemented in C, C++, Scala, Julia (the latter has a specific syntax for calling macros, as opposed to functions; for all languages, macros have very distinct semantics compared to functions — actually, on par with the contrast between a constructor and a method, both of which have different tags). Similar to
function.- macrosynopsis: a container for the description of a macro. Similar to
funcsynopsis.- macrosynopsisinfo: information supplementing the contents of a
macrosynopsis. Similar tofuncsynopsisinfo.- macroprototype: prototype of a macro (its name and its arguments). For instance, implemented in C, C++ (without type information for arguments), Scala, Julia (with facultative type information). Similar to
funcprototype.- macrodef: definition of a macro (return type and name). For instance, Scala and Julia may require the distinction between a
macrodefand amacro(macros may return a value). Similar tofuncdef.- enumname: the name of an enumerated type. For instance, implemented in C, C++, Scala, Julia.
- enumvalue: a possible value of an enumeration constant. For instance, implemented in C, C++, Scala, Julia.
- enumvalue: a possible value of an enumeration constant (usually, an integer). For instance, implemented in C, C++, Scala, Julia.
- enumidentifier: the mnemonic of an enumeration constant (usually, similar to a constant). For instance, implemented in C, C++, Scala, Julia.
- enumsynopsis: a container for the description of an enumeration and its enumerated values.
- enumsynopsisinfo: information supplementing the contents of an
enumsynopsis.- enumitem: a container for an enumerated value (both a value and an identifier).
- typedefname: the name of a type alias. For instance, implemented in C, C++, Scala (all with the keyword
typedef).- typedefsynopsis: a container for the description of a type alias.
Here are some parts that should be more carefully thought about.
- Need for separate
namespaceandnamespacename? I did this by consistency with classes, but I do not think there is a need for this. - Should macros be modelled after functions (
funcsynopsis) or methods (methodsynopsis)? The first one feels a bit awkward in DocBook (at least in 2018).
Here is an RNC description of all these tags:
default namespace = "http://docbook.org/ns/docbook"
include "docbookxi.rnc" {
db.classsynopsis =
element classsynopsis {
db.classsynopsis.attlist,
db.oo.inlines+,
(db.classsynopsisinfo
| db.methodsynopsis
| db.constructorsynopsis
| db.destructorsynopsis
| db.fieldsynopsis
| db.synopsis)*
}
}
db.synopsis = db.enumsynopsis | db.typedefsynopsis
# Deal with namespaces.
div {
## First the inline elements.
db.programming.inlines |= db.namespace | db.namespacename
db.namespace.role.attribute = attribute role { text }
db.namespace.attlist =
db.namespace.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.namespace = element namespace { db.namespace.attlist, db.namespacename }
db.namespacename.role.attribute = attribute role { text }
db.namespacename.attlist =
db.namespacename.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.namespacename = element namespacename { db.namespacename.attlist, db._text }
## Then the synopsis.
db.synopsis.blocks |= db.namespacesynopsis
db.namespacesynopsisinfo.role.attribute = attribute role { text }
db.namespacesynopsisinfo.attlist =
db.namespacesynopsisinfo.role.attribute?
& db.common.attributes
& db.common.linking.attributes
& db.verbatim.attributes
db.namespacesynopsisinfo =
element namespacesynopsisinfo {
db.namespacesynopsisinfo.attlist, db.verbatim.contentmodel
}
db.namespacesynopsis.role.attribute = attribute role { text }
db.namespacesynopsis.attlist =
db.namespacesynopsis.role.attribute?
& db.common.attributes
& db.common.linking.attributes
& db.language.attribute?
db.namespacesynopsis =
element namespacesynopsis {
db.namespacesynopsis.attlist,
db.programming.inlines+,
(db.namespacesynopsisinfo
| db.classsynopsis
| db.funcsynopsis
| db.fieldsynopsis
| db.typedefsynopsis
| db.macrosynopsis
| db.enumsynopsis)*
}
}
# Deal with macros. Adapted from db.funcsynopsis.
div {
## First the inline elements.
db.programming.inlines |= db.macro
db.macro.role.attribute = attribute role { text }
db.macro.attlist =
db.macro.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.macro =
element macro { db.function.attlist, db._text }
## Then the synopsis.
db.synopsis.blocks |= db.macrosynopsis
db.macrosynopsis.role.attribute = attribute role { text }
db.macrosynopsis.attlist =
db.macrosynopsis.role.attribute?
& db.common.attributes
& db.common.linking.attributes
& db.language.attribute?
db.macrosynopsis.info = db._info.title.forbidden
db.macrosynopsis =
element macrosynopsis {
db.macrosynopsis.attlist,
db.macrosynopsis.info,
(db.macrosynopsisinfo | db.macroprototype)+
}
db.macrosynopsisinfo.role.attribute = attribute role { text }
db.macrosynopsisinfo.attlist =
db.macrosynopsisinfo.role.attribute?
& db.common.attributes
& db.common.linking.attributes
& db.verbatim.attributes
db.macrosynopsisinfo =
element macrosynopsisinfo {
db.macrosynopsisinfo.attlist, db.verbatim.contentmodel
}
db.macroprototype.role.attribute = attribute role { text }
db.macroprototype.attlist =
db.macroprototype.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.macroprototype =
element macroprototype {
db.macroprototype.attlist,
db.modifier*,
db.macrodef,
(db.void
| db.varargs
| ((db.paramdef | db.group.paramdef)+, db.varargs?)),
db.modifier*
}
db.macrodef.role.attribute = attribute role { text }
db.macrodef.attlist =
db.macrodef.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.macrodef =
element macrodef {
db.macrodef.attlist, (db._text | db.type | db.macro)*
}
}
# Deal with enums.
div {
## First the inline elements.
db.programming.inlines |= db.enumname | db.enumvalue | db.enumidentifier
db.enumname.role.attribute = attribute role { text }
db.enumname.attlist =
db.enumname.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.enumname = element enumname { db.enumname.attlist, db._text }
db.enumvalue.role.attribute = attribute role { text }
db.enumvalue.attlist =
db.enumvalue.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.enumvalue = element enumvalue { db.enumvalue.attlist, db._text }
db.enumidentifier.role.attribute = attribute role { text }
db.enumidentifier.attlist =
db.enumidentifier.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.enumidentifier = element enumidentifier { db.enumidentifier.attlist, db._text }
## Then the synopsis.
db.synopsis.blocks |= db.enumsynopsis
db.enumitem.role.attribute = attribute role { text }
db.enumitem.attlist =
db.enumitem.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.enumitem = element enumitem { db.enumvalue.attlist, db.enumidentifier, db.enumvalue? }
db.enumsynopsisinfo =
element enumsynopsisinfo {
db.funcsynopsisinfo.attlist, db.verbatim.contentmodel
}
db.enumsynopsis.attlist =
db.common.attributes
& db.common.linking.attributes
& db.language.attribute?
db.enumsynopsis =
element enumsynopsis {
db.enumsynopsis.attlist,
db.programming.inlines+,
db.enumsynopsisinfo*,
db.enumitem*
}
}
# Deal with typedefs.
div {
## First the inline elements.
db.programming.inlines |= db.typedefname
db.typedefname.role.attribute = attribute role { text }
db.typedefname.attlist =
db.typedefname.role.attribute?
& db.common.attributes
& db.common.linking.attributes
db.typedefname = element typedefname { db.typedefname.attlist, db._text }
## Then the synopsis.
db.synopsis.blocks |= db.typedefsynopsis
db.typedefsynopsis.attlist =
db.common.attributes
& db.common.linking.attributes
& db.language.attribute?
db.typedefsynopsis =
element typedefsynopsis {
db.typedefsynopsis.attlist,
db.typedefname,
db.programming.inlines*
}
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
dourouc05 commentedon Mar 18, 2019
To address the comments I see in https://lists.oasis-open.org/archives/docbook-tc/201902/msg00017.html:
synopsisinfotag. I don't think it would be suitable to name itinfo, as the kind of information that would be stored in asynopsisinfowould be quite different: whereasinfois a wrapper around metadata, asynopsisinfois designed just to store one specific piece of information (e.g., inheritance for a class, the C/C++ header to include, whether a Java class isfinal).synopsisinfoshould be allowed everywhereclasssynopsisinfoandfuncsynopsisinfoare allowed, for sheer consistency (maybe deprecate it?).macrosynopsis).LarryRowland commentedon May 8, 2019
You have obviously put a lot of effort into this. I appreciate the work.
I did a pass at trying to represent an enumerated type in preparation for the most recent DocBook meeting and have a few comments that came up from attempting to use the schema. I thought it might be worth getting your insight on them.
Notes on
enumsynopsisa. some are obvious (color: red, blue, undefined)
b. some need extra information (setup: fast, normal, secure)
dourouc05 commentedon May 9, 2019
Thanks for your feedback! (In the following, I got rid the of *synopsisinfo to replace them with a generic synopsisinfo.)
[1, 2] Very much like a classsynopsis, this is not supported right now. The planned use is rather to have a section per item to document, then to start the section with a synopsis. The rest of the section would then describe the enum. I thought the proposed synopses are machine-readable, and not really as text. Nevertheless, having a possibility to include text within the elements would make sense, depending on how people want to use the tags.
[3] As such, these elements are not made to be rendered. In my use case, all of this is generated, and a human-readable version is spit out (mostly a section title).
[4] What about a new attribute for this? What would be a sensible default value? (There must be a default value. In my use cases, where I generate automatically a large quantity of documentation, there is no way of getting this kind of information, unfortunately...)
[5, 6] I followed what was already done in DocBook, with tags like classname. Similarly, a class describes a type, so I think it's the same issue.
[7] I made the name optional. The same could be done for classes, as anonymous classes also exist (I can only think of Java, though).
[8] I don't really get your point. What are these "additional attributes"? Can't you think of them as values? (I don't really understand your syntax either.)
[9] I really reduced the number of allowed items, many of them indeed made no sense.
[11] See later, I include a few of them.
First, here is the updated description. List of changes:
Here is an RNC description of all these tags:
Here are a few examples of how I use the tag set right now (edited for brevity).
A part of QFileInfo:
A short excerpt of Qt Namespace:
Now, a new version allowing for text inside. I considered these elements as equivalent to sections. The expected rendering would be to create a new section, the title being the *name tag at the beginning of the synopsis. After this title, the textual content of the synopsis tag should be output; then the items of the synopsis (enumitems, contents of a namespace, methods of a class).
The modifications: allow the synopses as top-level tags or anywhere a section is allowed; after the programming tags, allow text (including sections). It might make sense to disallow other programming synopses within this text (I suppose it is allowed with this RNC). Namespaces are an exception, with text allowed before the other synopses (a namespace can be very long, I guess the best mental model is to first have the description of the namespace, then its contents with their descriptions); the same reasoning could apply to classes as well.
Following your comments, I also added the enumitemdescription tag (I'm not exactly proud of the name...), to describe in detail a specific value of an enumeration (same content model as simpara).
From now on, it may be easier for everyone to use a pull request, so I could directly modify the DocBook schema locally (keeping in mind this is an extension), instead of having large chunks of code in comments. Should I go with or without descriptions within the synopses?
bobstayton commentedon Jun 12, 2019
Last month I posted to the Docbook mailing list your proposed schema changes to see if anyone had a comment. One response pointed out that a Google Summer of Code project had done something similar for C++, along with a stylesheet. That project was never adopted because it was too specific (C++ only). The DocBook TC was hoping you could take a look at this previous work to see: a) if your proposal covers the same territory but in more general terms to cover more languages, and b) if it contributes any new ideas for your proposal. Here is a link to that subproject on Github:
https://github.com/docbook/xslt10-stylesheets/tree/api/docbook/relaxng/api
dourouc05 commentedon Jun 12, 2019
I responded on the mailing list; do you need anything else? There are indeed a few functionalities that could be added, but nothing that revolutionises this proposal; I was waiting for an answer on whether text should be allowed in the synopses or not (see my previous comment) before going on in that direction.
dourouc05 commentedon Jun 22, 2019
Just to make it easier to collaborate, I uploaded the schema and the samples on a new repository: https://github.com/dourouc05/DocBookLibrary. I plan on adding new things from the existing API schema (and samples).
dourouc05 commentedon Aug 22, 2019
I've just updated both the table, the RNG, and the samples to include templates/generics/parametric types, with examples in C++, Java, and Julia (as the syntax is quite different in these three languages).
LarryRowland commentedon Sep 11, 2019
Sorry it has taken me so long to get back to you. Things have been pretty busy at work and that really slows down my participation in the DocBook TC.
I am not entirely confident with elevating these new elements to section-level equivalents. I think they are closer in concept to something like a formal table (or other formal elements that have titles). I suspect the RefEntry in DocBook (https://tdg.docbook.org/tdg/5.0/refentry.html) would be roughly the equivalent to what you are talking about (we should make the *synopsis elements valid children of refsynopsisdiv). This sounds much more like a formal element (basically, elements that have titles, so that they can show up in a list of tables, list of figures, etc.). I would lean towards continuing to use refentry elements to contain structured content associated with the *synopsis elements rather than spawn a new element that shows up in parallel with other structural elements when the element content is so highly specialized.
If the RefEntry element is too highly structured (it was originally developed to represent content that mapped to Unix Man pages which is very prescriptive to make it easy to summarize automatically) it would also be possible to use regular sections to contain additional content associated with a specific *synopsis element if the *synopsis elements block elements the same way the synopsis element is.
I hope I haven't missed what was driving you towards making these section-equivalent level elements, because I am very impressed with all that has gone into this so far.
dourouc05 commentedon Sep 20, 2019
Actually, my original plan was not to have the new synopses as equivalent to sections (what I have in mind is to start a section for documenting a function, an enum, whatsoever, then have a synopsis to formalise things, then more text for the doc). That equivalence came after your first set of comments (I thought it was your idea, with allowing text within the synopses), and has now been removed.
I don't think it's worth it to rework refentry to allow these synopses, as the content model is quite far away (much more prescriptive), the standard sections are more than enough.
dourouc05 commentedon Oct 15, 2019
Just for the record: this proposal is currently used in some tools I develop (https://github.com/dourouc05/QtDocTools), plus is getting integrated into Qt's qdoc (https://codereview.qt-project.org/c/qt/qttools/+/276759).
ndw commentedon Dec 12, 2019
There are a lot of new synopses in this proposal. A few illustrative examples of each new synopsis type would be helpful.
dourouc05 commentedon Dec 12, 2019
There are quite a few examples there: https://github.com/dourouc05/DocBookLibrary. Or would you need more of them?
bobstayton commentedon Dec 12, 2019
dourouc05 commentedon Dec 28, 2019
Following https://lists.oasis-open.org/archives/docbook-tc/201912/msg00003.html, if you need any help to create samples, doc, I can provide some (including PRs to the Definitive Guide).
Implement DocBook support for qdoc
11 remaining items
Added new markup for libraries docbook#111 (see docbook#111)
kosek commentedon Apr 19, 2020
@dourouc05 could you please look at https://github.com/kosek/docbook/blob/docbook-5.2-dev/relaxng/schemas/docbook/programming.rnc and fill in missing one sentence descriptions of new elements into placeholders marked with "FIXME". Ideally do this as a PR. Then I will be able to create PR against master schema repo and generated new beta release of DocBook schema with your additions.
dourouc05 commentedon Apr 19, 2020
#111 (comment)
That's fine for me!
dourouc05 commentedon Apr 19, 2020
#111 (comment)
That's more a lack of skill and/or habit with RelaxNG on my side :).
dourouc05 commentedon Apr 19, 2020
#111 (comment)
It's for modelling some enums like you have in C++, where you don't have to specify values for each enumerated value. In that case, you do not necessarily have a
enumvaluefor eachenumitem, but you can compute it, as long as you don't change anything in the order of theenumitems.dourouc05 commentedon Apr 19, 2020
#111 (comment)
I just made a PR for this: kosek#1.
kosek commentedon Apr 20, 2020
#111 (comment)
OK, I see. So this attribute can appear both on
enumsynopsisandunionsynopsiselements as union can contain enum type. Right?One more thing. We have to enumerate values for
orderedattribute in the schema. For few boolean values DocBook used values0and1and notfalseandtrue. I have also added short description for these two values (see kosek@53ba6a4) Please let me know if description should be changed/improved.Merge pull request #134 from kosek/docbook-5.2-dev
kosek commentedon Apr 20, 2020
This has been included in base schema in PR #134
dourouc05 commentedon Apr 20, 2020
Great 👍 !
bobstayton commentedon Jul 21, 2020
Norm Walsh has suggested 16 changes to the schema regarding these new synopsis elements. He presents his concerns in issues #143 and #144, and his proposed fixes in Pull Request #160. Please review and comment on these proposed changes.
ndw commentedon Aug 10, 2022
We believe that these issues are resolved in DocBook 5.2CR2. Thank you for your patience!