Table of Contents
Most of the modules and clients are written in the YCP programming language.
Although YCP itself offers more possibilities howto write comments, there are some quite strict rules that needs to be followed. Don't be afraid, they are easy to remember.
Every YaST package, you have installed on your system, has its
auto-generated HTML-based documentation in the
/usr/share/doc/packages/_package_name_/.../autodocs/
directory. This documentation is generated by the
ycpdoc script — part of
the yast2-devtools
package.
![]() | Important |
---|---|
To recognize the comment that should be processed for the autodocs, ycpdoc needs this syntax: /** * * slash and two asterisks identify the comment * for file headers, functions and variables * */
/*** * * slash and three asterisks identify the initial comment * of file (intro) * */ If you don't use two (or three) asterisks, the comment doesn't get processed at all. |
Here you can see all available options and arguments of the ycpdoc script. This is the /usr/lib/YaST2/bin/ycpdoc --help command output:
Usage: ycpdoc -h|--help|--man ycpdoc [-d <dir>] [-s <dir>] [-f html|xml] [-i] [-] [-o] [-wr] files.ycp... Options and Arguments: -h Show this help screen -d dir, --outputdir=dir Output files are placed to directory dir -s dir, --strip=dir Strip only dir when generating output files (default all). Remaining slashes are converted to double underscores. -f format, --format=format Produce output in given format, html or xml. The option may be repeated. HTML is the default. XML produces ycpdoc.xml, the DTD is not stable yet. -O file, --xml-output=file For xml output, write to file. The default is "ycpdoc.xml", not respecting outputdir. -i, --noindex Do not generate index.html (intro.html, files.html) - Write output to stdout. Do not generate indexes. If there are more input files, generate only one output html file -o, --oldindex Old style of index: creates only index.html -wr Do not warn about undeclared return types --state For debugging, prints the parsing state for each line.
This is the example of generated HTML-based documentation. Run the
command /usr/lib/YaST2/bin/ycpdoc
/usr/share/YaST2/modules/FileUtils.ycp and open the just
generated HTML files in some HTML browser. First of all, see
the one that contains FileUtils.html
in its name.
You can see all global functions and variables documented there. Functions also with their parameters, return types, examples, etc.
This example of generated XML-based documentation. Run the
command /usr/lib/YaST2/bin/ycpdoc --format=xml
/usr/share/YaST2/modules/FileUtils.ycp and see the just
generated ycpdoc.xml
XML file.
![]() | Note |
---|---|
XML is not for humans, it's optimized for computers. That's also why the XML output of ycpdoc doesn't so look nice but it's very valuable for text-processing tools. |
Example 1.1. Examplary XML output reformated and shortened by hand
<?xml version="1.0" encoding="UTF-8"?> <ycpdoc> <files> <file_item key="usr/share/YaST2/modules/FileUtils.ycp"> <header> <authors> <ITEM>author</ITEM> </authors> <file>modules/FileUtils.ycp</file> <module>YaST2</module> <summary>summary</summary> </header> <provides> <provides_item> <descr></descr> <example_file></example_file> <file>usr/share/YaST2/modules/FileUtils.ycp</file> <global>1</global> <kind>function</kind> <name>Exists</name> <parameters> <parameters_item> <name>target</name> <type>string</type> </parameters_item> </parameters> <return>true if exists</return> <scruple></scruple> <see></see> <short>short description</short> <type>boolean</type> </provides_item> ... </provides> <requires> <requires_item> <kind>import</kind> <name>SCR</name> </requires_item> ... </requires> </file_item> </files> </ycpdoc>