Skip to content

Conversation

mkitti
Copy link
Contributor

@mkitti mkitti commented Aug 1, 2021

Add basic help "command" to InteractiveUtils

Typing "help" into an interactive command line program is an intuitive step to take when working with a new program. This pull request creates a "help" command by creating a singleton Help object in InteractiveUtils and a constant instance help.

julia> help
  Welcome to Julia 1.8.0-DEV.289. The full manual is available at

  https://docs.julialang.org

  as well as many great tutorials and learning resources:

  https://julialang.org/learning/

  For help on a specific function or macro, type ? followed by its name, e.g. ?cos, or ?@time, and press enter. Type ; to
  enter shell mode, ] to enter package mode.

julia> help()
  Welcome to Julia 1.8.0-DEV.289. The full manual is available at

  https://docs.julialang.org

  as well as many great tutorials and learning resources:

  https://julialang.org/learning/

  For help on a specific function or macro, type ? followed by its name, e.g. ?cos, or ?@time, and press enter. Type ; to
  enter shell mode, ] to enter package mode.

While this has some redundancy with ? (mentioned in the banner) and @doc, the redundancy is worthwhile to make Julia user friendly and assists the users when the banner may not be visible after executing several commands.

Background

Julia before this pull request

Currently, typing "help" into the Julia REPL results in an error message.

julia> help
ERROR: UndefVarError: help not defined

julia> help()
ERROR: UndefVarError: help not defined
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

Pkg help

In contrast, the Pkg mode:

(@v1.6) pkg> help
  Welcome to the Pkg REPL-mode. To return to the julia> prompt, either press
  backspace when the input line is empty or press Ctrl+C.

  Synopsis
...

Python

Compare this to Python/ipython:

In [1]: help
Out[1]: Type help() for interactive help, or help(object) for help about object.

In [2]: help()

Welcome to Python 3.7's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at https://docs.python.org/3.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help>  # interactive prompt

R

> help()
# paginated ...
help                   package:utils                   R Documentation

Documentation

Description:helpis the primary interface to the help systems.

Usage:

     help(topic, package = NULL, lib.loc = NULL,
          verbose = getOption("verbose"),
          try.all.packages = getOption("help.try.all.packages"),
          help_type = getOption("help_type"))

While Base.banner() does direct users to ?

Implementation Notes

  • The help "command" is added to the InteractiveUtils stdlib as a singleton instance of a Help struct.
  • Base.show is implemented for Help by showing the result of Base.Docs.parsedoc(Base.Docs.keywords[:help])
    • Changing this @doc(help) seems to fail
  • The struct is callable and results in showing the same text.
  • Currently calling the struct takes no arguments. We don't want to reimplement help mode or @doc.

@Seelengrab
Copy link
Contributor

I think a NEWS entry would be good, since that's one more exported-by-default identifier.

@DilumAluthge
Copy link
Member

In previous discussions, I think we've said that it would be better to implement this kind of thing in the REPL code.

@mkitti
Copy link
Contributor Author

mkitti commented Aug 14, 2021

Closing due to merge of #41754, which shows the error and does not define a help symbol.

@mkitti mkitti closed this Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants