Explorar o código

pythonlib: basic description of standard options and flags for script doc

 * link to C API beacuse there is no other list of std options and flags
 * mention --script flag (but also source code since --script does not give standard options and flags)
 * mention also pylint besides pep8 (unfortunately, PEP8 does not allow #% but not mentioning that for now)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63403 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras %!s(int64=10) %!d(string=hai) anos
pai
achega
93aadb1b04
Modificáronse 1 ficheiros con 22 adicións e 1 borrados
  1. 22 1
      lib/python/docs/src/script_intro.rst

+ 22 - 1
lib/python/docs/src/script_intro.rst

@@ -132,7 +132,28 @@ Providing GRASS module interface to a script
     if __name__ == "__main__":
     if __name__ == "__main__":
         sys.exit(main())
         sys.exit(main())
 
 
+The options which has something like ``G_OPT_R_INPUT`` after the word
+``option`` are called standard options. Their list is accessible
+in GRASS GIS `C API documentation`_ of ``STD_OPT`` enum from ``gis.h`` file.
+Always use standard options if possible. They are not only easier to use
+but also ensure consistency across the modules and easier maintanenace
+in case of updates to the parameters parsing system.
+Typically, you change ``description`` (and/or ``label``), sometimes ``key``
+and ``answer``. There are also standard flags to be used
+with ``flag`` which work in the same way.
+
+The examples of syntax of options and flags (without the ``G_OPT...`` part)
+can be obtained from any GRASS module using special ``--script`` flag.
+Alternatively, you can use GRASS source code to look how different scripts
+actually define and use their parameters.
+
 Note that the previous code samples were missing some whitespace which
 Note that the previous code samples were missing some whitespace which
 Python PEP8 style guide requires but this last sample fulfills all the
 Python PEP8 style guide requires but this last sample fulfills all the
 requirements. You should always use *pep8* tool to check your syntax and
 requirements. You should always use *pep8* tool to check your syntax and
-style or set your editor to do it for you.
+style or set your editor to do it for you. Note also that although
+a some mistakes in Python code can be discovered only when executing
+the code due to the dynamic nature of Python, there is a large number
+of tools such as *pep8* or *pylint* which can help you to identify problems
+in you Python code.
+
+.. _C API documentation: http://grass.osgeo.org/programming7/gis_8h.html