none
How to add descriptions and comments to own functions

Answers

  • Hi Imke,

    Here's how to add the necessary metadata to a custom function query called "MyFunction":

    = let
     func = () as number => 123,
     documentation = [
      Documentation.Name = "MyFunction",
      Documentation.Description = "Returns a shiny new number.",
      Documentation.LongDescription = "Returns a magical, shiny, brand-new number.",
      Documentation.Category = "Number",
      Documentation.Examples = {[Description = "The first example.", Code = "MyFunction()", Result = "123"]}
     ]
    in
     Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))

    Ehren

    Friday, May 20, 2016 9:57 PM
    Owner

All replies

  • They're in function's type's metadata:

    = Value.Metadata(Value.Type(List.Select))

    I haven't tried, but you're probably able to do it with putting htmls in function type's metadata?

    Friday, May 20, 2016 8:31 PM
    Moderator
  • Hi Imke,

    Here's how to add the necessary metadata to a custom function query called "MyFunction":

    = let
     func = () as number => 123,
     documentation = [
      Documentation.Name = "MyFunction",
      Documentation.Description = "Returns a shiny new number.",
      Documentation.LongDescription = "Returns a magical, shiny, brand-new number.",
      Documentation.Category = "Number",
      Documentation.Examples = {[Description = "The first example.", Code = "MyFunction()", Result = "123"]}
     ]
    in
     Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))

    Ehren

    Friday, May 20, 2016 9:57 PM
    Owner
  • Perfect!

    Thanks a lot Ehren.


    Imke Feldmann TheBIccountant.com

    Saturday, May 21, 2016 3:18 AM
    Moderator
  • Is there also a way to set the function signature, eg "function (list as list, selection as function) as list" for a custom function?
    Tuesday, May 16, 2017 11:48 AM
  • Hi Frank. No, that part is derived from the M itself. What were you hoping to change about it?

    Ehren

    Tuesday, May 16, 2017 5:07 PM
    Owner
  • Hi Ehren. I just think the signature should be part of the documentation record.
    Wednesday, May 17, 2017 8:55 AM
  • Hi Frank,

    The function signature is in fact a direct representation of the function type, so why would you want to copy the same information into your documentation record?

    Marcel

    Wednesday, May 17, 2017 9:33 AM