Page MenuHomePhabricator

WikiLambda: Add in-product guidance re: use of Wikifunctions.Debug
Closed, ResolvedPublic

Description

Description

Evaluated implementations (implementations written in one of the supported programming languages, such as JavaScript or Python) can generate tracing strings for debugging purposes. To increase awareness of this feature, and to be helpful to our contributors, add the following context-appropriate guidance in Wikifunctions' UI:

  • When a call to an evaluated function returns an error, add a banner like this at the top of the Details (metadata) dialog: Something not working? Try Wikifunctions.Debug to trace your code. Ideally, this would also be linked to appropriate documentation. See the attached image.
  • When Wikifunctions.Debug output appears in the Details dialog, and no errors are returned, either suggest or require (TBD) that it should be removed from the code. If it's a requirement, it could appear as in the attached image (and additional code will be needed to enforce the requirement). If a suggestion, the wording could be Consider removing Wikifunctions.Debug before publishing

These are just 2 possibilities; there are others that can be considered. For example, guidance could be provided next to the code editor, or next to "Results" in the function evaluator widget.

Thanks to Amin Al Hazwani for these ideas and for the images!

For more info about Wikifunctions.Debug, see https://meta.wikimedia.org/wiki/Abstract_Wikipedia/Updates/2024-01-25.

Devices and Design (URLs or screenshots)

  • Desktop:

DebugGuidance.png (1×2 px, 395 KB)

DebugGuidance2.png (738×1 px, 91 KB)


Completion checklist

Event Timeline

As I read this there are 2 suggestions above:

  1. Explain to the user that they can use WikiFunctions.Debug for debugging their implementation code when their tests fail on the edit/create new implementation page. (Preferable with a link to some documentation on Wikifunctions.Debug: do we have that?)
  2. On the same edit/create implementation page:
    • submit alert the user that they can not publish an implementation with Wikifunctions.Debug in the 'code' field and disable the publish button. Or;
    • on submit warn the user that they should not publish an implementation with Wikifunctions.Debug in the 'code' field

But we can also go this way:

  1. if a function execution fails, we suggest people to debug it using "wikifunctions.Debug"
  2. if a function is not failing anymore, and it uses "wikifunctions.Debug", we suggest the user to remove the debugging code

The only place I think we can do this is in the FunctionMetadataDialog.

Waiting for product decision.

We go for the initial 2 approaches as mentioned. The wording should be something like 'Consider removing Wikifunctions.Debug before publishing' because for debugging purposes they might want to leave the Debug code in for a bit.

Change #1122534 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] Wikifunctions.Debug: Add in-product guidance re: use of Wikifunctions.Debug

https://gerrit.wikimedia.org/r/1122534

Info message shown in the Metadata Dialog when forcing an error:

  • Go to page for Z802 and click "Run function" without setting any input

Screenshot from 2025-02-27 10-48-09.png (617×574 px, 43 KB)

Warning message shown in the Publish Dialog when saving an implementation that uses debug:

  • Create a new implementation and select "code"
  • Write a debugging line "Wikifunctions.Debug();"
  • Click publish

Screenshot from 2025-02-27 10-54-31.png (466×562 px, 43 KB)

Change #1122534 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Wikifunctions.Debug: Add in-product guidance re: use of Wikifunctions.Debug

https://gerrit.wikimedia.org/r/1122534