mattermost / mattermost-developer-documentation

Mattermost developer documentation.
https://developers.mattermost.com
BSD 3-Clause "New" or "Revised" License
80 stars 389 forks source link

Help Wanted: Default parameters are not correctly rendered in plugin registry methods #627

Open agarciamontoro opened 4 years ago

agarciamontoro commented 4 years ago

See, for example, registerAdminConsoleCustomSetting, where showTitle is missing:

image

This happens because the default parameters have a different structure in the AST returned by the parser.

akshitarora921 commented 2 years ago

Hi, Can I take this?

agarciamontoro commented 2 years ago

All yours, @akshitarora921, thanks for working on this :)

akshitarora921 commented 2 years ago

Hi @agarciamontorom, I have a little doubt, According to my research the registry data is coming from {{<pluginjsdocs>}} from line 81 from file /mattermost-developer-documentation/site/content/integrate/plugins/webapp but to generate its data we need to run command make plugin-data and generate json files and we are interested in PluginJSDocs.json path site/data/PluginJSDocs.json but I see that json file is also in .gitignore file. So, where do I need to make the change? as json change will not reflect in the repo. Go is quite new to me, please pardon me if I am wrong.

akshitarora921 commented 2 years ago

PluginJSDocs.json image

akshitarora921 commented 2 years ago

ooh this is just an adventure through all the files. Correct me if I am wrong. when we run command it actually runs this

rm -rf scripts/mattermost-webapp
    cd scripts && git clone https://github.com/mattermost/mattermost-webapp.git
    cd scripts && npm install
    mkdir -p site/data
    node scripts/plugin-jsdocs.js > site/data/PluginJSDocs.json

and get data from this https://github.com/mattermost/mattermost-webapp/blob/master/plugins/registry.js and spits out PluginJSDocs.json which we are displaying.

Conclusion

we need to make change in file https://github.com/mattermost/mattermost-webapp/blob/master/plugins/registry.js to be precise line 197 and whole snippet will look like

store.dispatch({
            type: ActionTypes.RECEIVED_PLUGIN_POST_COMPONENT,
            data: {
                id,
                pluginId: this.id,
                type,
                component,
                showTitle
            },
        });
akshitarora921 commented 2 years ago

but then how showTitle is coming now🤔

agarciamontoro commented 2 years ago

Great investigation, @akshitarora921! This is definitely a code maze.

I think the problem is not in the definition of the functions (mattermost-webapp/blob/master/plugins/registry.js) but with how we retrieve the data from them in the little script in mattermost-developer-documentation/blob/master/scripts/plugin-jsdocs.js. I believe that the problem may lay in this line: I guess that statement.value.params contain only the non-optional parameters.

I would try to look into how this data is structured. We parse the file with espree at the beginning of the script, so I'd look into the espree API to see if we're missing something important there. Maybe espree simply does not parse optional parameters? I'm not sure :thinking:

akshitarora921 commented 2 years ago

@agarciamontoro this is getting more and more interesting, whenever I look into it. Kudos to the developers who wrote this. 🙌🏼

cwarnermm commented 2 years ago

@akshitarora921 - Are you actively working on this ticket?

akshitarora921 commented 2 years ago

No

agarciamontoro commented 2 years ago

Thanks for the answer, @akshitarora921, and for all your work!

Feel free to get back at it if you want to, I'll mark the issue up for grabs again.

agarciamontoro commented 2 years ago

Whoops, I didn't mean to close the issue. Reopening :)

akshitarora921 commented 2 years ago

@agarciamontoro @cwarnermm I will try it. If I solve it, I will ask you to assign me again.

cwarnermm commented 1 year ago

@akshitarora921 - Are you actively working on this ticket?

akshitarora921 commented 1 year ago

@cwarnermm No