OpenHausIO / documentation

Documentation about Frontend, Backend, Installation & Administration
https://docs.open-haus.io
MIT License
4 stars 1 forks source link

Add a "shadow" property flag #35

Open mStirner opened 7 months ago

mStirner commented 7 months ago

Sometimes there are hidden/private properties on class/item. To document them, a possibility should be added to mark them as private/hidden/shadow.

E.g.:

class Notification{
    constructor(title, message) {

        let { error, value } = Notification.validate({
            title,
            message
        });

        if (error) {
            throw error;
        }

        // set/merge default values
        Object.assign(this, value);

        // hidden property
        Object.defineProperty(this, "published", {
            value: false,
            writable: true
        });

    }
}

The published property is used for internal purpose only, but needs to be documented. Typical documentation of a class looks like this:

/**
 * @description
 * Represents a room item
 * 
 * @class Room
 * 
 * @param {Object} obj Object that matches the item schema. See properties below:
 * 
 * @property {String} _id MongoDB Object is as string
 * @property {Number} [number=null] Room number
 * @property {Number} [floor=null] Floor on which the room is located
 * @property {String} [icon=null] fontawesome class string for the frontend
 */

Add a flag/bit/marker like this?:

@property {Boolean} [published=null,hidden] Notification already published?

-- or --

@property {Boolean} [published=null,shadow=true] Notification already published?

But what about necessary/non default values props?:

/**
 * @description
 * Device item in component `.items` array
 * 
 * @class Device
 * 
 * @param {Object} props Object that matches the item schema. See properties below:
 * 
 * @property {String} _id MongoDB Object id is as string
 * @property {String} name Human readable name
 * @property {String} room Simle identifier to find the secret when you need it
 * @property {Boolean} enabled Can we read/write data to/from the device
 * @property {Array} interfaces Objects that match the interface schema
 * 
 * @see interface components/devices/class.interface.js
 * @see interfaceStream components/devices/class.interfaceStream.js
 */