Hey fellow Techies and hope you are having great time at E3, if you went there!
Intro
I’m probably gonna start documenting most of the tools I’ve written soon.
I really like Data-Driven programming, I use it whenever it’s appliable.
For those who do not know data driven programming; say that I have a sortable, filterable asset browser. I want to consume same code for photoshop and maya. The flow of the application changes depending on different data, where data is either xml / ini / json or from db etc.
The data could say only show .psd files for photoshop and .ma / .mb files for maya or only search in x, y folders for the assets etc.
Documentation
I want to apply the same rules to documentation, and potentially consume some parts of the documentation in the UI. I dont’ want to document stuff just because noone will ever read it.
I want to consume parts of it in tooltips, in help buttons, help centers etc, related topics etc.
So data driven documentation is what I had in mind.
So I will have an XML file containing the documentation
Example Documentation Data:
<documentations>
<documentation xml:id="PhysX">
<title>NVIDIA PhysX dynamics</title>
<author>Yasin Uludag</author>
<tooltip>this is the tooltip that will be shown</tooltip>
<description>we should have a long description here</description>
<howto>
<step>1. First</step>
<step>2. Seconds</step>
<step>3. Last</step>
</howto>
</documentation>
</documentations>
Now the idea is to be able to consume this DATA at the same time as using it for DOCUMENTATION.
Say that the documentation is HTML code.
To satisfy that: documentation could be generated using XQuery expressions.
For those who do not know: XQuery is to XML what SQL is to database tables.
Qt has a module called QtXmlPatterns, which allows us to use XPath, XQuery, XSLT and XML Schema validation
I hope you are with me up untill now!
Example XQuery expression:
declare variable $inputDocument external;
doc($inputDocument)/documentations/documentation/
<generated>
<p><span style=" font-size:11pt; font-weight:600;">
Title: { string(title) }
</span></p>
<p> Author: { string(author) } </p>
<p><strong> Short description: </strong> { string(tooltip) } </p>
</generated>
which unfolds to, after using QtXmlPatters module:
<generated>
<p><span style=" font-size:11pt; font-weight:600;">
Title: NVIDIA PhysX dynamics
</span></p>
<p> Author: Yasin Uludag</p>
<p><strong>Short description: </strong> this is the tooltip that will be shown</p>
</generated>
So now I have generated the HTML code required for the documentation content, where it can contain long descriptions, detailed steps, links, embedded movies etc.
This output can be injected to any html documentation code. I didn’t generate all of the elements from our original XML, wanted to keep it simple!
Also the original XML only contained one entry of documentation, XQuery expressions runs for every entry it finds with the matched pattern so the expression will never grow once it has been estabilished!
The plan now is to CONSUME the original XML file in our UI by making an interface class that allows us to query and adapt the data! Smallest example would be tooltips.
So summary:
Xml contains all documentation.
XQuery expressions generates HTML code for documentations with all different properties using a pattern. Could also generate entire HTML pages and upload to Wikis.
Documentation interface / adaptor class allows us to query tool tips, short descriptions and other useful doc to our UI from the XML and not the wiki / html
Feedback:
I’m gonna be open, it will be my first time documenting code, I’m very open to feedback. I don’t want to document something that goes to waste because noone cares. I want to document and be able to make it apart of my UI! So I sat down and thought how I could do this, and this method that I explained blossomed.
Still, feedback is very important to me
Best regards Yasin!