GCuser99 / SeleniumVBA

A comprehensive Selenium wrapper for browser automation developed for MS Office VBA running in Windows
MIT License
89 stars 18 forks source link

Help Documentation #45

Closed GCuser99 closed 1 year ago

GCuser99 commented 1 year ago

... at least a tabular object model description, ideally auto-generated directly from the code base using VBIDE and @Description annotations and VB attributes.

6DiegoDiego9 commented 1 year ago

Here is my fast base extraction loop for the '@ModuleDescription and '@Description annotations in all Web* objects of the project:

Sub Draft()
    Dim VBComp As vbide.VBComponent, row As Long, strRow As String
    For Each VBComp In ThisWorkbook.VBProject.VBComponents
        If VBComp.Name Like "Web*" Then
            For row = 1 To VBComp.CodeModule.CountOfLines
                strRow = VBComp.CodeModule.Lines(row, 1)
                Dim oRegex As New VBScript_RegExp_55.regexp
                oRegex.IgnoreCase = True
                If row <= VBComp.CodeModule.CountOfDeclarationLines Then
                    oRegex.Pattern = "^\s*'@ModuleDescription ""([^""]*)"""
                    If oRegex.test(strRow) Then
                        Debug.Print "Module: " & VBComp.Name & ", ProcDesc: " & oRegex.Replace(strRow, "$1")
                        GoTo nextRow
                    End If
                End If

                oRegex.Pattern = "^\s*'@Description\(""(.*?)""\)"
                If oRegex.test(strRow) Then
                    Dim procSpecs As String, procDesc As String
                    procDesc = oRegex.Replace(strRow, "$1")
                    row = row + 1
                    strRow = VBComp.CodeModule.Lines(row, 1)
                    oRegex.Pattern = "^([^']*).*$"
                    procSpecs = oRegex.Replace(strRow, "$1")

                    Debug.Print "Module: " & VBComp.Name & ", ProcSpecs: " & procSpecs & ", ProcDesc: " & procDesc
                End If
nextRow:
            Next
        End If
    Next
End Sub
GCuser99 commented 1 year ago

Very cool! Is there a way to get the procedure types and input parameters?

6DiegoDiego9 commented 1 year ago

Very cool! Is there a way to get the procedure types and input parameters?

Edited now with the procedure details added and better parsing. Note: ":" and " _" (line-continuation) situations not supported

GCuser99 commented 1 year ago

@6DiegoDiego9 the Wiki is live now (but under construction). You do have write access in case that you want to contribute to topics (add/modify/delete). Note that the Object Model Overview page is completely automatically generated from the code base so I suggest not making any changes in the Wiki for that particular page, but instead change the sources (RD procedure descriptions, etc). Thanks for your help!

GCuser99 commented 1 year ago

closed

6DiegoDiego9 commented 1 year ago

@GCuser99 Wow! wonderful work!!