Jump to content

ParseHeadersToSciTE() - Parse include headers to the appropriate format for SciTE calltips and properties.


Recommended Posts

Posted

Just a quick snippet I created to parse UDF headers into the format used by SciTE for calltips and properties. This came about as I was constantly having to mess around with the files for >ResourcesEx UDF and overtime it became quite laborious.

#include <FileConstants.au3>
#include <WinAPIShPath.au3>

Local $sFileOpenDialog = FileOpenDialog('Select an Au3 script file with headers.', @ScriptDir & '\', 'Au3 Script (*.au3)', $FD_FILEMUSTEXIST)
If Not @error Then
    Local $sOutput = ParseHeadersToSciTE($sFileOpenDialog)
    ConsoleWrite($sOutput)
    ClipPut($sOutput)
EndIf

Func ParseHeadersToSciTE($sFilePath)
    Local Enum $PARAMS_FUNCTIONNAME, $PARAMS_DESCRIPTION, $PARAMS_PARAMSIGNATURE
    Local $sReturn = ''
    Local $aSRE = StringRegExp(FileRead($sFilePath), '(?is:\R;\hName\h\.+:\h(\w+)\h*\R;\hDescription\h\.+:\h(.+?)\R;\hSyntax\h\.+:\h(\1.+?)(?=\R;\hParameters\h\.))', $STR_REGEXPARRAYGLOBALMATCH)
    If Not @error Then
        Local $iFuncCount = 0, _
                $sCallTips = '', $sProperties = '', $sUDFName = _WinAPI_PathStripPath($sFilePath)
        For $i = 0 To UBound($aSRE) - 1 Step 3
            $iFuncCount += 1
            $sCallTips &= StringRegExpReplace($aSRE[$i + $PARAMS_PARAMSIGNATURE], '\h*\R;\h+', '') & ' ' & $aSRE[$i + $PARAMS_DESCRIPTION] & ' (Requires: #include <' & $sUDFName & '>)' & @CRLF
            $sProperties &= StringLower($aSRE[$i + $PARAMS_FUNCTIONNAME]) & ' '
            If Not Mod($iFuncCount, 5) Then
                $sProperties &= '\' & @CRLF & @TAB
                $iFuncCount = 0
            EndIf
        Next
        If Mod($iFuncCount, 5) Then
            $sProperties &= '\'
        EndIf
        $sReturn = 'Add to au3.user.calltips.api:' & @CRLF & $sCallTips & @CRLF & 'Add to au3.userudfs:' & @CRLF & $sProperties & @CRLF
    EndIf
    Return $sReturn
EndFunc   ;==>ParseHeadersToSciTE

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

This script return also internal function.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Probably. But then I don't use headers with internal functions, only functions accessed by the user.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...