[XWiki Docs Reorg - Batch 17]: Template for Documenting Rendering Macros

Hello! :waving_hand:

Proposal 23: Template for Documenting Rendering Macros

To ease the process of documenting rendering macros and ensure consistency, macro documentation pages must follow a predefined structure. The type of the page, according to Diataxis is of type Reference.

Proposed Structure for a Rendering Macro Reference Page

  1. Description: A short and clear explanation of what the macro does, its purpose, and typical use cases.
  2. Parameters: A standardized table listing all parameters with the following fixed column format:
    |=Name|=Mandatory|=Allowed Values|=Default Description
  • Name: name of the parameter
  • Mandatory: Yes/No
  • Allowed Values: accepted data types
  • Default: value used when none is specified
  • Description: what the parameter does and any relevant notes
  1. Examples: Example/s using the Wiki Syntax must be included, showing realistic usage. Examples using the WYSIWYG editor could be included.

Note: This can be implemented either as a page template or using a class + sheet.

Page Titles for Rendering Macros and UIXPs

To avoid conflicts with existing page title rules (e.g., All how-to's and tutorials must start with a verb. (Doc guide-Page titles), pages that document structured information such as rendering macros and UIXPs, must follow dedicated rules. Therefore, page titles for rendering macro and UIXP documentation must use the following conventions:

  • Macro Pages: Page titles must contain quotes around the macro name and must include the word “macro”, e.g., "Display" macro.
    • This avoids ambiguity with how-to pages.
  • UIXP Pages: Page titles must contain quotes around the UIXP name and must include the word “UIXP”, e.g., “Add Application” UIXP.
    • This prevents confusion with how-to/tutorial titles (e.g., "Add application" UIXP vs. Add application as a how-to).

Note: Similarly, rendering macros and UIXPs often require page names that may already be taken, we need a generic rule for resolving naming conflicts when a contributor tries to create a page with an existing name in the same location.
Therefore, this is proposed:

Page Naming Conflict Guidelines

When you want to create a page but another page with the same name already exists in that location, follow these guidelines:

  • Add additional details to the name of one of the pages.
    • These details must not describe the page’s target or type, since that information is already included in the URL.
  • The additional details must not violate existing page-naming rules.

WYT? Thanks!

I think the current proposal is fine for nominal cases but is not covering the full complexity of macro parameters.
I’m thinking, for instance, of groups or advanced parameters. You can find the full list of macro annotations in xwiki-commons/xwiki-commons-core/xwiki-commons-properties/src/main/java/org/xwiki/properties/annotation at master · xwiki/xwiki-commons · GitHub

The proposal is to implement it using a Class/Sheet and introduce a UIXP in the docapp’s documentation sheet.

This is mostly for the WYSIWYG macro dialog but indeed, it could be interesting to document them (it’s more work though). I wonder if we have an example in the existing doc where we documented that.

Thanks for the info! I found some additional info here: Stable order for macro parameters. I’m wondering if advanced parameters can be documented in the Optional section. Since they are not displayed from the beginning, nor mandatory. And mentioning the details about their advanced nature in the description section?

I don’t feel it’s important to document most parameters, they only make sense for the WYSIWYG and reading them doesn’t bring much value IMO. For ex, what’s the interest to know that such param has order 3?

  • Advanced: Not really useful in the doc
  • Description: already there
  • DisplayHidden: maybe useful so that readers know why they won’t see the parameter displayed
  • DisplayType: already covered by the “allowed value” column
  • Feature: already covered by the “mandatory” column + “description”?
  • Group: already covered by the “mandatory” column
  • Hidden: feels too technical
  • Id: already covered by the param name column
  • Mandatory: already covered by the “mandatory” column
  • Name: only for WYSIWYG. Could be interesting since the property id is not displayed in the WTSIWYG UI AFAIK.
  • Order: doesn’t seem useful to document

WDYT?

I think indeed the columns already listed in the

could cover the parameters that are interesting to use.

We don’t need a column for that, but we could ask documentation writers to put simple parameters before advanced ones. IMO it’s just common sense so I agree we don’t have to add anything.

Some features have a complex group/mandatory pattern. E.g. only one in the group has to be filled up for the macro to work as intended. I’m not sure it’d be good to describe it in the “mandatory” column (lot of repeated text). Note that this could be described with asterisks and a footnote. It will be useless on most simple macros so I agree to not add a column for it.


Overall I agree with this. The technical annotations can be documented on the generic macro doc for devs, and we can safely assume the devs can check the exact values themselves if that’s what they are looking for.


+1 for the structure proposed. I think the flexibility of a template would be better than using a class+sheet even if it’s worst for long-term maintanibility. Having a specific tag or badge on the templates or anything to make them easily filterable would be useful though :slight_smile:

Thanks!
Lucas C.

1 Like

The structure would be very high level:

  • A property for the Description
  • A property for the Parameters
  • A property for the Examples

So don’t think there would be a flexibility issue.

2 Likes

I’ve now implemented it and you can see it in action on https://www.xwiki.org/xwiki/bin/view/documentation/xs/user/icons/displayicon-macro/

However if you edit it, you’ll see that we are missing a “Usage” section…

I’ve cheated and added a heading in the Description for it but it’s not right.

I’ve created Improvement #51: Add a "Usage "section when display rendering macro

It’s missing the Default Value. Should be:

|=Name|=Mandatory|=Allowed Values|=Default Value|=Description

I’ve implemented it and released v1.8 of the Doc App + updated xwiki.org and updated the 2 macros doc pages.

1 Like