Skip to content

Commit

Permalink
Better handling of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rkapl123 committed Dec 14, 2024
1 parent 563d023 commit 11ba34b
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 29 deletions.
Binary file modified Distribution/DBaddin32.xll
Binary file not shown.
Binary file modified Distribution/DBaddin64.xll
Binary file not shown.
42 changes: 21 additions & 21 deletions docs/DBFuncs.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,38 +338,38 @@ If the setting `ConfigSelect` (or any other ConfigSelect, see [Other Settings](h

#### Viewing Database documentation with configurations

If the setting `ConfigDocQuery` is being filled with a query that retrieves documentation for database objects in the below described way, then clicking the entries in the config dropdown with Ctrl or Shift provide the documentation of the tables/views. `ConfigDocQuery` can be given either per environment or globally (without an environment).
If the setting `ConfigDocQuery` is being filled with a query that retrieves documentation for database objects in the below described way, then clicking the entries in the config dropdown with Ctrl or Shift provides the documentation of the tables/views. `ConfigDocQuery` can be given either per environment or globally (without an environment).

ConfigDocQuery is a query against the currently active environment for retrieving the data for the documentation. This query needs to return three fields for each table/view/field object:
ConfigDocQuery is a query against the currently active environment for retrieving the documentation data. This query needs to return three fields for each table/view/procedure/function/field object:
1. database of the object (only really needed for tables/views),
2. table/view name (for fields this is the parent table/view) and
2. table/view/procedure/function name (for fields this is their parent object) and
3. the documentation for the object.

The data has to be ordered by table/view name, with the table/view objects in the first place.
The data has to be ordered by object name, with the table/view/procedure/function objects coming first (before their fields), the documentation built by simply aggregating the documentation text for one table/view/procedure/function object with the documentation texts of its fields (no CR/LF, this needs to be provided by the query).

Following query is an example how this can be retrieved from a very minimalistic demo table `dbdocumentation` for the pubs database (the creation script is provided [here](dbdocumentation.sql)):
`SELECT databasename,case when objecttype='T' then objectname else parenttable end, case when objecttype='F' then objectname + ': ' else '' end + documentation FROM dbdocumentation ORDER BY case when objecttype='T' then objectname+'1' else parenttable+'2' end, objectname`
`SELECT databasename,case when objecttype='T' then objectname else parenttable end, case when objecttype='F' then objectname + ': ' + documentation + CHAR(10) else objectname + ': ' + documentation + CHAR(10) + CHAR(10) end FROM dbdocumentation ORDER BY case when objecttype='T' then objectname+'1' else parenttable+'2' end, objectname`

Result:

|database|table/view name|documentation|
|---|---|---|
|pubs|authors|table authors contains the book authors|
|NULL|authors|au_fname: firstname of authors|
|NULL|authors|au_id: id of author|
|NULL|authors|au_lname: lastname of author|
|NULL|authors|city: city of author|
|NULL|authors|contract: flag for contract|
|NULL|authors|phone: phone of author|
|NULL|authors|state: state of author|
|NULL|authors|zip: zip code of author|
|pubs|discounts|discounts per store|
|NULL|discounts|discount: amount of discount|
|NULL|discounts|discounttype: type of discount|
|NULL|discounts|stor_id: reference to store|
|pubs|employee|employees table|
|NULL|employee|emp_id: employee id|
|NULL|employee|fname: firstname of employee|
|pubs|authors|authors: table authors contains the book authors + CHAR(10) + CHAR(10)|
|NULL|authors|au_fname: firstname of authors + CHAR(10)|
|NULL|authors|au_id: id of author + CHAR(10)|
|NULL|authors|au_lname: lastname of author + CHAR(10)|
|NULL|authors|city: city of author + CHAR(10)|
|NULL|authors|contract: flag for contract + CHAR(10)|
|NULL|authors|phone: phone of author + CHAR(10)|
|NULL|authors|state: state of author + CHAR(10)|
|NULL|authors|zip: zip code of author + CHAR(10)|
|pubs|discounts|discounts: discounts per store + CHAR(10) + CHAR(10)|
|NULL|discounts|discount: amount of discount + CHAR(10)|
|NULL|discounts|discounttype: type of discount + CHAR(10)|
|NULL|discounts|stor_id: reference to store + CHAR(10)|
|pubs|employee|employee: employees table + CHAR(10) + CHAR(10)|
|NULL|employee|emp_id: employee id + CHAR(10)|
|NULL|employee|fname: firstname of employee + CHAR(10)|
|...|...|...|

To be able to link the documentation to the config entries, which are retrieved from the filesystem, another setting is needed that indicates the first character in the `specialConfigStoreFolders` as discussed in [Creating configurations](#creating-configurations): `<add key="charBeforeDBnameConfigDoc" value="_" />`.
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DBAddin.NET is the successor to the VB6 based Office Database Add-in, see also t
If any of these are missing, please install them yourself before starting DBAddin.

Download the latest zip package in [https://github.com/rkapl123/DBAddin/tags](https://github.com/rkapl123/DBAddin/tags), unzip to any location and run deployAddin.cmd in the folder Distribution.
This copies DBAddin.xll, DBAddin.xll.config, DBAddinUser.config and DBAddinCentral.config to your %appdata%\Microsoft\AddIns folder and starts Excel for activating DB Add-in (adding it to the registered Add-ins).
This copies DBAddin.xll, DBAddin.xll.config, DBAddinUser.config and DBAddinCentral.config to your %appdata%\Microsoft\AddIns folder and tries to register in HKEY_CURRENT_USER\Software\Microsoft\Office\<OfficeVersion>.0\Excel\Options\OPEN to activate DB Add-in (if this is not successful you have to register it yourself in the Add-ins).

### Settings

Expand Down
2 changes: 1 addition & 1 deletion source/DBAddinCentral.config
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<add key="ConfigSelect" value="SELECT TOP 10 (SELECT Count(*) FROM !Table!) Anzahl, * FROM !Table!" />
<add key="ConfigSelect1" value="SELECT TOP 10 * FROM !Table!" />
<add key="ConfigSelect2" value="SELECT * FROM !Table!" />
<add key="ConfigDocQuery" value="SELECT databasename,objectname,documentation FROM dbdocumentation ORDER BY case when objecttype='T' then objectname+'1' else parenttable+'2' end, objectname" />
<add key="ConfigDocQuery" value="SELECT databasename,case when objecttype='T' then objectname else parenttable end, case when objecttype='F' then objectname + ': ' + documentation + CHAR(10) else objectname + ': ' + documentation + CHAR(10) + CHAR(10) end FROM dbdocumentation ORDER BY case when objecttype='T' then objectname+'1' else parenttable+'2' end, objectname" />
<add key="charBeforeDBnameConfigDoc" value="_" />
<add key="CmdTimeout" value="30" />
<add key="CnnTimeout" value="15" />
Expand Down
9 changes: 9 additions & 0 deletions source/DBaddin.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
<Compile Include="AddInEvents.vb" />
<Compile Include="DBConnHelper.vb" />
<Compile Include="ConfigFiles.vb" />
<Compile Include="DBDocumentation.Designer.vb">
<DependentUpon>DBDocumentation.vb</DependentUpon>
</Compile>
<Compile Include="DBDocumentation.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="DBSheetConfig.vb" />
<Compile Include="DBSheetCreateForm.designer.vb">
<DependentUpon>DBSheetCreateForm.vb</DependentUpon>
Expand Down Expand Up @@ -200,6 +206,9 @@
<DependentUpon>AboutBox.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="DBDocumentation.resx">
<DependentUpon>DBDocumentation.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="DBModifCreate.resx">
<DependentUpon>DBModifCreate.vb</DependentUpon>
<SubType>Designer</SubType>
Expand Down
4 changes: 2 additions & 2 deletions source/Functions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1473,9 +1473,9 @@ err: LogWarn(errMsg + ", caller: " + callID)
End If
End If
currTableName = recordset.GetValue(1)
ConfigDoc = If(recordset.IsDBNull(2), "", recordset.GetValue(2) + vbCrLf)
ConfigDoc = If(recordset.IsDBNull(2), "", recordset.GetValue(2))
Else
ConfigDoc += If(recordset.IsDBNull(2), "", recordset.GetValue(2) + vbCrLf)
ConfigDoc += If(recordset.IsDBNull(2), "", recordset.GetValue(2))
End If
End While
getConfigDocCollection.Add(charBeforeDBnameConfigDoc + DBName + "\" + currTableName + ".xcl", ConfigDoc)
Expand Down
9 changes: 7 additions & 2 deletions source/MenuHandler.vb
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,15 @@ Public Class MenuHandler
''' <param name="control"></param>
Public Sub getConfig(control As CustomUI.IRibbonControl)
If My.Computer.Keyboard.CtrlKeyDown Or My.Computer.Keyboard.ShiftKeyDown Then
' Key: charBeforeDBnameConfigDoc + DBName + "\" + TableName + ".xcl", control.Tag is full path to xcl config file
' so prune control.Tag starting with last folder (being charBeforeDBnameConfigDoc + DBName)
Dim ConfigDocKey = Mid(control.Tag, InStrRev(control.Tag, "\", InStrRev(control.Tag, "\") - 1) + 1)
Dim DocMessage As String = "No Documentation for Config Object"
Dim DocMessage As String = "No Documentation for Config Object " + ConfigDocKey
If Not IsNothing(ConfigDocCollection) AndAlso ConfigDocCollection.ContainsKey(ConfigDocKey) Then DocMessage = ConfigDocCollection(ConfigDocKey)
UserMsg(DocMessage, "DBAddin: Documentation for Config Object", 0)
With New DBDocumentation()
.DBDocTextBox.Text = DocMessage
.Show()
End With
Else
ConfigFiles.loadConfig(control.Tag)
End If
Expand Down
4 changes: 2 additions & 2 deletions source/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ Imports System.Runtime.InteropServices
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:

<Assembly: AssemblyVersion("1.0.0.77")>
<Assembly: AssemblyFileVersion("1.0.0.77")>
<Assembly: AssemblyVersion("1.0.0.78")>
<Assembly: AssemblyFileVersion("1.0.0.78")>
<Assembly: NeutralResourcesLanguage("de-DE")>
Binary file modified test/DBFuncsTest.xls
Binary file not shown.

0 comments on commit 11ba34b

Please sign in to comment.