-
-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docbuild: switch from optparse to argparse #31366
Comments
comment:1
Setting new milestone based on a cursory review of ticket status, priority, and last modification date. |
comment:3
a little bit in #32331 |
Branch: public/ticket/31366 |
Commit: |
comment:4
first tentative New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Author: Frédéric Chapoton |
comment:8
not quite sure that it works perfectly, but it seems so |
comment:9
needs work
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
This comment has been minimized.
This comment has been minimized.
comment:12
I'm getting the message |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:23
more progress done. |
comment:24
and the bot+linter are now green ; still needs tests and double-check, for sure |
comment:25
Looks very close now, docs build and tests pass. The old version exited gracefully with the help message if you ran Another difference. Old:
New:
Any idea why it's not preserving the line breaks in the help message? We could try the following changes, but I would like to understand why it's not respecting our formatting for the strings. diff --git a/src/sage_docbuild/__init__.py b/src/sage_docbuild/__init__.py
index 1f692f1abe..84a6444ec1 100644
--- a/src/sage_docbuild/__init__.py
+++ b/src/sage_docbuild/__init__.py
@@ -1385,9 +1385,6 @@ def help_description(s="", compact=False):
character.
"""
s += "Build or return information about Sage documentation.\n\n"
- s += " DOCUMENT name of the document to build\n"
- s += " FORMAT document output format\n"
- s += " COMMAND document-specific command\n\n"
s += "Note that DOCUMENT may have the form 'file=/path/to/FILE',\n"
s += "which builds the documentation for the specified file.\n\n"
s += "A DOCUMENT and either a FORMAT or a COMMAND are required,\n"
@@ -1625,8 +1622,10 @@ def setup_parser():
help="if ARG is 'reference', list all subdocuments"
" of en/reference. If ARG is 'all', list all main"
" documents")
- parser.add_argument("document", nargs='?', type=str)
- parser.add_argument("format", nargs='?', type=str, choices=get_formats())
+ parser.add_argument("document", nargs='?', type=str,
+ help='name of the document to build')
+ parser.add_argument("format", nargs='?', type=str, choices=get_formats(),
+ help='document output format')
return parser
@@ -1722,7 +1721,8 @@ def main():
# trying to build.
name, typ = args.document, args.format
if not name or not type:
- raise ValueError('both document and format should be given')
+ parser.print_help()
+ sys.exit(1)
# Set up module-wide logging.
setup_logger(args.verbose, args.color) |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:28
here is a new tentative |
comment:29
Looks good. I have a few more proposed changes: two of the "examples" in |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:31
A bit more explanation: |
comment:32
Ready for review? I am happy with your changes. |
Reviewer: John Palmieri |
comment:34
I would say so. I have forgotten if there were remaining issues or not. |
Dependencies: #32946 |
comment:36
Okay, let's merge it. (I added #32946 as a dependency because otherwise there would be a merge conflict.) |
Changed branch from public/ticket/31366 to |
Sage's docbuilding uses optparse for argument parsing, but this library has been deprecated for a while. We should switch to argparse.
Some instructions for conversions can be found here: https://docs.python.org/3/library/argparse.html#help
Depends on #32946
Component: documentation
Author: Frédéric Chapoton
Branch/Commit:
0b62c16
Reviewer: John Palmieri
Issue created by migration from https://trac.sagemath.org/ticket/31366
The text was updated successfully, but these errors were encountered: