diff --git a/docs/scripting.xml b/docs/scripting.xml
index a028430eb..25a096469 100644
--- a/docs/scripting.xml
+++ b/docs/scripting.xml
@@ -3409,6 +3409,213 @@ local localip, localport = client_service:get_info()
+
+ Script Documentation Writing
+ Nmap Scripting Engine (NSE)Documentation Writing
+
+
+ Scripts are used by more than just the author, so it is useful to have
+ documentation for users and other developers to browse through
+ when looking
+ for scripts to run against a host. For this reason,
+ NSE provides a system
+ that will produce complete documentation for its library
+ of scripts.
+
+
+ The documentation
+ is put in comments around your code. The trigger for a
+ documentation comment is ---. Only the first
+ line in the block of comments should use the prefix trigger;
+ subsequent lines should use Lua's standard single line comment
+ prefix: --.
+
+
+ The first paragraphs are used as a description for the code
+ following the comments. The first sentence of this description
+ is used as a summary (for a brief description in the index).
+ Optional tags can follow the description using the format
+ @tag .... See
+ for more information.
+
+
+ The first comment block not followed by a function or table
+ definition will
+ be used for a file's comment. This comment will serve for documenting
+ general information concerning the script. The description of this
+ tag should explain the script's purpose and what it does.
+ The file comment should also
+ contain an output tag showing expected output for the script and
+ an args tag for any arguments the script expects.
+
+
+
+ Documentation Format
+
+ Documentation for a script consists of three basic parts: a file
+ comment, a function or table comment, and standard NSE script fields
+ (e.g. description or author).
+ A file comment is the first documentation comment in a script and
+ is not followed by a function definition or table. The following
+ example demonstrates a file comment:
+
+--- Checks if an FTP server allows anonymous logins.
+-- @output
+-- |_ Anonymous FTP: Anonymous login allowed"
+
+ The standard NSE fields are used to gather other information about a
+ script such as the author or its categories:
+
+author = "Eddie Bell"
+license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
+id = "Anonymous FTP"
+categories = {"default", "intrusive"}
+
+ These fields will be present in the final documentation. The
+ description field is used for the User Summary if a description in
+ the file comment or the file comment itself is absent. It is best
+ if the description field is succinct while the file comment has an
+ extensive description of the script.
+
+
+ Finally, a documentation comment may precede a function or
+ table definition:
+
+--- Convert two bytes into a 16bit number.
+--@param data String of data.
+--@param idx Index in the string (first of two consecutive bytes).
+--@return 16 bit number represented by the two bytes.
+function bto16(data, idx)
+ local b1 = string.byte(data, idx)
+ local b2 = string.byte(data, idx+1)
+ -- (b2 & 0xff) | ((b1 & 0xff) << 8)
+ return bit.bor(bit.band(b2, 255), bit.lshift(bit.band(b1, 255), 8))
+end
+
+ You may also choose to document the action, portrule, or hostrule
+ functions. They are separated from other functions in the final
+ documentation for improved visibility.
+
+
+
+ Tags
+
+ The following tags can be used:
+
+
+
+
+
+
+ Describe function parameters. The first alphanumeric word
+ must be the parameter being documented.
+
+
+
+
+
+
+
+ Refer to other functions or tables.
+
+
+
+
+
+
+
+ Describe the return values of a function.
+
+
+
+
+
+
+
+ Describe the usage of a function or variable.
+
+
+
+
+
+
+
+ The description of a function or table; this is normally
+ inferred from the beginning of the documentation comment.
+
+
+
+
+
+
+
+ The name of the function or table definition. This should
+ be used only if the documentation system cannot infer the
+ name by code analysis.
+
+
+
+
+
+
+
+ Like @name, if the name of the variable
+ is not being correctly inferred through code analysis, you
+ may specify the class (function or table) explicitly.
+
+
+
+
+
+
+
+ Describe a table field definition.
+
+
+
+
+
+
+
+ Free format string to describe the module or file release.
+
+
+
+
+
+
+
+ This tag is special to the file comment. It allows you specify
+ arguments to the script (via --script-args) that your script
+ uses. The first alphanumeric word (literally matching in Lua
+ ([%w%p]+)) is used as the name for
+ the argument, the rest its description.
+
+
+
+
+
+
+
+ This allows you to specify the summary explicitly different
+ from the first sentence of the description.
+
+
+
+
+
+
+
+ This tag is special to thie file comment. It allows you to
+ show typical output of a script. You may use "\n" to
+ force a line break where you please.
+
+
+
+
+
+
+
Version Detection Using NSENmap Scripting Engine (NSE)sample scripts