PSDocs.Azure icon indicating copy to clipboard operation
PSDocs.Azure copied to clipboard

Add support for user-defined function

Open GABRIELNGBTUC opened this issue 8 months ago • 2 comments

Is your feature request related to a problem? Please describe.

User-defined function are now in GA and it would be interesting for documentation to be generated for them

Describe the solution you'd like

PSDocs generate documentation on user-defined function

GABRIELNGBTUC avatar Apr 22 '25 08:04 GABRIELNGBTUC

We have a collection of utility user-defined functions that are exported and used in multiple other modules. It would be nice to see this get supported.

SangMinhTruong avatar May 13 '25 09:05 SangMinhTruong

@SangMinhTruong

Unfortunately this tool seems abandoned now. We just forked it there https://github.com/GABRIELNGBTUC/PSDocs.Azure/tree/master, published the resulting module in an Universal artifact on ADO and load the module from our pipelines for use with PSDocs.

We also added several improvements like compiling the json from a bicep file if using PSCore and bicep is installed from path, support for UDFs, UDTs, links to the correct type when using a UDT, ... So you could technically use that as a base for your own fork.

Example:

module.bicep:

type test = {
  str: string
  integer: int?
  boolean: bool?
  second: secondType?
}

type secondType = {
  text: 'test'
  secondText: 'test' | 'not test'
  integer: 1 | 2 | 30
}

type thirdType = {
  returnToFirstType: test
}

param text test
param third thirdType = {
  returnToFirstType: text
}

resource res 'Microsoft.Compute/virtualMachines@2024-03-01'= {
  name: 'myVM'
  location: ''
}

func returnOut(param1 string) test => {str: 'test'}



output out test = returnOut('')


module.md:

Azure template

User-defined types definitions

test

Property name Type Nullable Description Allowed values
str string False Any
integer int True Any
boolean bool True Any
second #/definitions/secondType True Any

secondType

Property name Type Nullable Description Allowed values
text string False test
secondText string False not test | test
integer int False 1 | 2 | 30

thirdType

Property name Type Nullable Description Allowed values
returnToFirstType #/definitions/test False Any

Functions

returnOut

Parameter name Type
param1 string

output

Type: #/definitions/test

@{str=test}

Parameters

Parameter name Required Type Description
text Yes #/definitions/test
third No #/definitions/thirdType

text

Parameter Setting

third

Parameter Setting

Default value

{
    "returnToFirstType": "[parameters('text')]"
}

Outputs

Name Type Description
out #/definitions/test

Snippets

Parameter file

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "metadata": {
        "template": null
    },
    "parameters": {
        "text": {
            "value": null
        },
        "third": {
            "value": {
                "returnToFirstType": "[parameters('text')]"
            }
        }
    }
}

GABRIELNGBTUC avatar May 14 '25 07:05 GABRIELNGBTUC