Fix displaying commands source code in sage backend
ClosedPublic

Authored by arojas on Jul 9 2018, 2:39 PM.

Details

Summary

Typing foo?? in sage displays the source code of the foo command. This doesn't work in cantor, since it converts it to help(foo?), which gives an error.

Test Plan

foo?? displays the source code of foo, foo? displays help for foo as before

Diff Detail

Repository
R55 Cantor
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
arojas created this revision.Jul 9 2018, 2:39 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptJul 9 2018, 2:39 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
arojas requested review of this revision.Jul 9 2018, 2:39 PM

Hi, thanks for patch.
I am afraid, that @filipesaraiva don't active in Cantor in this moment, so I recommend change @filipesaraiva to @asemke: another active Cantor developer.
What about removing this if condtions at all?

-        if(command.endsWith(QLatin1Char('?')) && !command.endsWith(QLatin1String("??")))
-            command=QLatin1String("help(")+command.left(command.size()-1)+QLatin1Char(')');
-        if(command.startsWith(QLatin1Char('?')))
-            command=QLatin1String("help(")+command.mid(1)+QLatin1Char(')');

As I see, this code don't need, because sage understand foo? and ?foo as help request, so we don't need change foo? and ?foo to help(foo) command. And this also make the source code command (foo??) working.

arojas added a comment.Jul 9 2018, 4:15 PM

As I see, this code don't need, because sage understand foo? and ?foo as help request, so we don't need change foo? and ?foo to help(foo) command. And this also make the source code command (foo??) working.

Yeah I didn't want to touch that as I assumed it was there for some reason. From a quick look, with those lines help text seems to be displayed in a sllightly more user-friendly way: A first line is added with "Help for foo" and some technical snippets are removed from the top and bottom.

sirgienko accepted this revision.Jul 9 2018, 4:25 PM

As I see, this code don't need, because sage understand foo? and ?foo as help request, so we don't need change foo? and ?foo to help(foo) command. And this also make the source code command (foo??) working.

Yeah I didn't want to touch that as I assumed it was there for some reason. From a quick look, with those lines help text seems to be displayed in a sllightly more user-friendly way: A first line is added with "Help for foo" and some technical snippets are removed from the top and bottom.

Yes, you right, I haven't notice this.

This revision is now accepted and ready to land.Jul 9 2018, 4:25 PM
This revision was automatically updated to reflect the committed changes.