Skip to content

REFACTOR: build help pages instead of printing them#9253

Merged
amtoine merged 9 commits intonushell:mainfrom
amtoine:refactor/stdlib/build-help-pages-instead-of-printing-them
May 26, 2023
Merged

REFACTOR: build help pages instead of printing them#9253
amtoine merged 9 commits intonushell:mainfrom
amtoine:refactor/stdlib/build-help-pages-instead-of-printing-them

Conversation

@amtoine
Copy link
Copy Markdown
Member

@amtoine amtoine commented May 20, 2023

Description

in order to write tests for the std help commands, as we currently have in the Rust source base, we need to be able to manipulate the output of the std help commands.

however, until now they've all been directly printing the help pages as they go...

this PR tries to build the help pages and return them at the end instead of printing them on the fly 👍

Note
this is quite a rewrite of the help.nu module 🤔
i think it might be best to either

  • look at the commits in order
  • test the changes by testing the commands in the REPL and comparing them to their previous std help versions

User-Facing Changes

$nothing

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • toolkit test
  • toolkit test stdlib

After Submitting

$nothing

@amtoine amtoine added the A:std-library Defining and improving the standard library written in Nu label May 20, 2023
@amtoine amtoine self-assigned this May 20, 2023
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 20, 2023

i'm just missing the parameters and flags part of show-command 🤔
fixed in 2e75122

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 20, 2023

i'm a bit off with some newlines and minor format details, but i think it's ready for review 😌

if any reviewer find something off, i'll change it, that should only be small tweaks 😉

@amtoine amtoine marked this pull request as ready for review May 20, 2023 16:52
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 20, 2023

and after a quick test, it looks around as slow as before... (:laughing:)

amtoine added 2 commits May 24, 2023 18:57
i've applied `%s/else \[\]/else { [] }` in *neovim* to replace
them all 👌
This should solve the merge conflicts in nushell#9253 introduced by nushell#9245.
@amtoine amtoine requested a review from fdncred May 25, 2023 16:54
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 25, 2023

@fdncred

i ping you for review if you want to have a look before merging 😉

i think it looks ok and should not introduce too many differences with the previous version.
and that would open the important door of testing the std help module 😋

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 25, 2023

@amtoine What do I have to do to test it? I've tried use std help then std help modules but that doesn't work any longer.

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 25, 2023

@amtoine What do I have to do to test it? I've tried use std help then std help modules but that doesn't work any longer.

i think jakub broke the prelude in this recent PRs 👀
working on it... ♻️

you'd have to run

use std
std help modules

or

use std help
std help

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 25, 2023

Thanks, that helped. Here's my feedback.

  • std help = good to go
  • std help help = good to go (except we should proably remove/change the help str lpad since that's deprecated)
  • std help str lpad = not a fan of the "This command:" section. I'm not sure users care about that information.
    maybe a different format would be more acceptible, so it doesn't take 7 lines? perhaps this?
[] scope [x] builtin [x] subcommand [] plugin [] custom [] keyword
  • std help aliases = good to go
  • std help commands = good to go. signatures are different but i'm not sure that matters that much
  • std help -f arg = seems like we need to work on usage versus extra_usage. I really don't like seeing so much information in the usage but i don't think there's a way to make extra_usage in custom commands yet.
  • std help externs = good to go
  • std help externs -f update - coloring is broken on the last line of usage. i wonder if that's a nushell bug?
  • std help modules = good to go
  • std help operators = good to go
  • std help operators -f math = good to go
  • std help dirs = i like the old format/look better (highlighted aliases, exported commands don't have command in parens).
    just speculating i wonder if it would be more helpful to show something like?
    [[exported_command exported_alias]; [add enter] [drop dexit] [goto g] [next n] [prev p] [show shells]]
  • std help xml (or any other std cmd)
    not sure about the "Help pages from external command xml"
    • it's not external
    • it's in italic and looks odd

Did i miss anything?

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 25, 2023

@fdncred
i'll check that more closely tomorrow 😌 😉

one question though: the bad points above have been created with this PR or were there before?
if the latter, i'd rather fix them once we write tests for the std help commands, if that's ok with you 😊

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 25, 2023

the bad points above have been created with this PR

This PR. I only checked this PR compared to before this PR.

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 26, 2023

This PR. I only checked this PR compared to before this PR.

perfect 👌

i'm having a look at the points above right now 😏

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 26, 2023

mm i'm a bit confused, all the points you list above look they were there before this PR 😕

i even feel they are tracked in the bounty for the most part 😮

looks to me we can merge this and address these one at a time next 😌
but yeah i still agree these are issues to be addressed 👍

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 26, 2023

I think the problem is that PRs keep getting submitted that don't fix the issues so I end up reviewing PRs over and over again and each PR has the same issues. Maybe going forward we should fix the issues before fixing internal things like build vs print. I really don't want to look at several issues and decide whether I've asked for a fix for this particular thing or not before commenting on it. It makes it really difficult to review PRs that way.

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 26, 2023

that's true 👍

but at the same time, this PR was meant to be a step forward to allow us write tests for the std help commands!
until now we've only been eye-balling what does not work.
with this PR, we'll hopefully be able to write Nushell tests for these, as it's done in the Rust side

@amtoine amtoine merged commit 6481bf2 into nushell:main May 26, 2023
@amtoine amtoine deleted the refactor/stdlib/build-help-pages-instead-of-printing-them branch May 26, 2023 09:22
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 26, 2023

i'll continue working on stabilizing the std help commands... 😌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:std-library Defining and improving the standard library written in Nu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants