c++ - Should I use polyglot documentation? -
It is possible to touch a C ++ source file with an HTML document:
// & lt ;; [Ignore [/ *]] & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Example & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; P & gt; Example & lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt ;! [IGNORE [* / #include & lt; Iostream & gt; Int main (int argc, char ** argv) {std :: cout & lt; & Lt; "Hello, world! \ N"; } / *]] & Gt; & Lt ;! [IGNORE [* / /]] & gt;
This leaves a passage //
at the beginning of the HTML document, which is
... & lt; Body & gt; & Lt; Div id = "main" & gt; & Lt; / Div & gt; & Lt; / Body & gt; ...
The content is styled to fill the content area with opaque background:
#main {background: #ffffff; Left: 0; Status: Completed; Top: 0; }
Is it a good idea to write code like this? It is more flexible than toxicon, but still allows to use quite structured formats, such as the DocBook, the advantage of this is that the source file is not only included documentation, but Naming or adding a source file to a file name ending in the documentation .htm
is enough to be read by a web browser as HTML.
The only problem is that in the beginning, the + C comment XML document, which should (prevent me from correct if I am wrong)
edit : & lt ;!
& lt ;! -... ---- & gt; To avoid conflict with
to -
.
Combining languages (in this case C ++ and HTML) is never a good thing, and Should be done at least whenever possible. It annoys the actual code and makes it less readable (many, in fact). As long as it is not possible by the policies of the company, I ask all questions on the use of inline documents. The code can be read and understood easily, standing on your side. As a developer, I do not want to use the code's parallel help file; It's just tedious.
There are exceptions, of course, as in when you are developing a closed source library, the libraries can not read the user code, so they need an option. I will use something like Doxygen, but only for the public API, no internal code will be documented in such a way; There should be no need for this, otherwise it should be refined.
I never mix raw HTML and code. It's just very ugly if you think that raw HTML will be easy in case of your use, then I recommend placing it in a parallel file of source code, e.g., Fu. CPP and FU In this way, this code will not interfere in reading, and it will still be easy to maintain.
Comments
Post a Comment