-- Running this code from Noteapd++ will transform
-- PaneAPI.html into Lua comments parseable by LDoc
local SCFIND_DOTMATCHESNL = 0x10000000 -- boost regex specific
npp:DoOpen(npp:GetCurrentDirectory() .. "\\PaneAPI.html")
editor:BeginUndoAction()
-- Remove everything up to and replace it with the header
for m in editor:match([[\A.*\r\n]], SCFIND_REGEXP | SCFIND_DOTMATCHESNL) do m:replace([[--- Scintilla wrapper.
-- This is a straight forward API to directly control Scintilla. This documentation is not intended to fully describe the Scintilla API, but only to give a brief description. The [official Scintilla documentation](http://www.scintilla.org/ScintillaDoc.html) should be consulted for more details. All constants from the official documentation are exposed as Lua globals variables.
--
-- Some Scintilla messages, such as "SCI_SETxxx" and "SCI_GETxxx", are implemented in LuaScript as a single property. For example `Editor.CurrentPos` is a read/write property that calls both "SCI_GETCURRENTPOS" and "SCI_SETCURRENTPOS". The automatically generated documentation below may only refer to one or the other.
--
-- This class cannot be instantiated, rather predefined globals are available to use.
--
-- * `editor` - the currently selected editor
-- * `editor1` - the first editor (usually on the left)
-- * `editor2` - the second editor (usually on the right)
-- * `console` - the console's output editor used by LuaScript. Note that since this editor is "read-only" some functionality may not work as expected, e.g. manually adding or removing text.
-- * `input` - the console's input editor used by LuaScript.
--
-- **Note:** Although the entire Scintilla API is available, a few parts of it should not be used since it would either have unexpected results, or does not make sense to use from Lua.
-- @classmod Editor
--- Helper Methods
-- @section helpermethods
--- Gets the text within a range.
-- @function textrange
-- @tparam int startPos
-- @tparam int endPos
-- @treturn string
--- Finds the next match within the document.
-- See the [Scintilla Documentation](http://www.scintilla.org/ScintillaDoc.html#searchFlags) for the search flags.
-- @function findtext
-- @tparam string search string
-- @tparam[opt] int flags either 0 or a combination of SCFIND constants
-- @tparam[opt] int startPos start of the range to search
-- @tparam[opt] int endPos end of the range to search
-- @return the start and end of the first match, or nil if no match
--- Creates a generator to iterate matches.
-- See the [Scintilla Documentation](http://www.scintilla.org/ScintillaDoc.html#searchFlags) for the search flags.
-- @function match
-- @tparam string search string
-- @tparam[opt] int flags either 0 or a combination of SCFIND constants
-- @tparam[opt] int startPos start of the range to search
-- @treturn Match match object generator
-- @see Match
-- @usage for m in editor:match(text, flags) do
-- ...
-- end
--- Appends text to the end of the document.
-- @function append
-- @tparam string text
-- Inserts text at the specified position.
-- @function insert
-- @tparam int pos position to insert the text
-- @tparam string text text to insert
--- Removes the text in the range.
-- @function remove
-- @tparam int startPos
-- @tparam int endPos
--- Sets the text direction.
-- @function set_text_direction
-- @tparam string direction either "RTL" or "LTR"
]]) end
-- Remove everything after
for m in editor:match([[.*\z]], SCFIND_REGEXP | SCFIND_DOTMATCHESNL) do m:replace("") end
-- Do a bit of cleanup when properties are "read-only"
for m in editor:match([[ read-only(?=<)]], SCFIND_REGEXP) do m:replace(' -- read-only') end
-- Replace any h2 headers and make them into doc sections
for m in editor:match([[[ \t]+
(.+?)