Skip to content
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

Add unified 'sphinx' command (WIP!) #6938

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

stephenfin
Copy link
Contributor

Feature or Bugfix

  • Feature

Purpose

Rather than having multiple separate executables - sphinx-build,
sphinx-quickstart, etc. - add a single sphinx command with multiple
subcommands.

Detail

TODO.

Relates

  • N/A

Let argparse do the heavy lifting here for us.

Signed-off-by: Stephen Finucane <stephen@that.guru>
@stephenfin
Copy link
Contributor Author

@tk0miya I've only ported two of the four commands currently available in tree as part of this PR. Before I work on the remainder, I have a few questions I'd like your input on.

  1. Does this idea make sense and are you happy with the approach?
  2. I'm not planning to migrate makemode because I don't like it and don't think it's necessary as noted at Add 'Builder.epilog' attribute #4354 (comment). Do you agree?

Use argparse's built-in functionality to handle these as part of the
parsing process itself, rather than as an afterthought. This changes
behavior somewhat, as we'll now fail on the first missing file rather
than list all missing files, but that doesn't seem like such a bad
thing.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Once again, this moves the logic into argparse and away from the meat
of our application.

Signed-off-by: Stephen Finucane <stephen@that.guru>
This will form the basis of a future 'sphinx' executable and
subcommands.

Signed-off-by: Stephen Finucane <stephen@that.guru>
This will make an upcoming diff far easier to read.

Signed-off-by: Stephen Finucane <stephen@that.guru>
This is the same as 'sphinx-quickstart' and represent the first step
towards a unified executable.

Note that this might look like a big diff, but most of it is just
indentation due to the use of the class.

Signed-off-by: Stephen Finucane <stephen@that.guru>
As seen previously, this will make an upcoming diff far easier to read.

Signed-off-by: Stephen Finucane <stephen@that.guru>
This is the same as 'sphinx-build' and represent the second step towards
a unified executable.

Signed-off-by: Stephen Finucane <stephen@that.guru>
@stephenfin
Copy link
Contributor Author

As noted at #6939 (comment), another thing we could do here in change the behavior of the outputdir and maybe the sourcedir options for sphinx build. We could transition from:

sphinx-build sourcedir outputdir file_a file_b ...

to

sphinx build sourcedir file_a file_b ...

This would mean we'd need to be able to define outdir somewhere else. I'm suggesting conf.py (and later sphinx.ini, when I finally finish that work). We could provide a vanity option for people that really didn't want to do this, of course:

sphinx build -o outdir sourcedir file_a file_b

@tk0miya
Copy link
Member

tk0miya commented Dec 22, 2019

Does this idea make sense and are you happy with the approach?

Yes, of course! I just read a part of this patch yet. There might be trivial comments and requests later. But it looks good to me. I'll continue to read this later (maybe my new years task!).

I'm not planning to migrate makemode because I don't like it and don't think it's necessary as noted at #4354 (comment). Do you agree?

+1. new sphinx command should not follow historical interfaces. We can forget both make and non-make mode!

@stephenfin
Copy link
Contributor Author

Good to hear. I am holding off on this until I determine whether I can configure the output directory as an optional flag (so sphinx build -o outdir srcdir instead of sphinx build srcdir outdir), as discussed at #6939 (comment). Other people have suggested this idea, such as #5618 (comment) though I disagree with -c conf.py being almost required. I'd prefer to default srcdir to the current directory.


return parser

def run(self, argv: List[str]) -> int:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call initialization of locales at beginning of the application.

    sphinx.locale.setlocale(locale.LC_ALL, '')
    sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

except ValueError:
pass
confoverrides['html_context.%s' % key] = val
return BuildCommand._run(args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss sphinx build (new stye) is same as sphinx-build (old style). I still don't have an answer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only behavior change I've suggested so far is to go from:

sphinx-build sourcedir builddir [file, ...]

to

sphinx build sourcedir [file, ...] [-o builddir]

But perhaps there are other options that we think are badly named and should be renamed now? I hadn't thought of that so good idea 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an idea, sphinx build html is so so good to me.

help=__('quiet mode'))
parser.add_argument('--version', action='version', dest='show_version',
version='%%(prog)s %s' % __display_version__)
'sphinx init' is an interactive tool that asks some questions about your
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some tools, init subcommand goes project initialization silently. So I wonder we should separate quickstart feature into sphinx init and sphinx quickstart (?) (or sphinx init --interactive).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking of git init? I think it's okay for sphinx init to be interactive, so long as you can specify these options from the command line and avoid the interactive prompts. We do need some way to retrieve required information like project and author.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was thinking of git init and bundle init. But I found npm init asks questions interactively. So please forget my comment.

We do need some way to retrieve required information like project and author.

Actually, project and author are not required configuration. So we can suppress all of questions.

Copy link
Contributor Author

@stephenfin stephenfin Dec 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, project and author are not required configuration. So we can suppress all of questions.

Oh, I didn't know that. Good to know. However, is it really useful to ignore these? What advantage would sphinx init provide over touch conf.py if we didn't ask for these? I think it makes sense to ask for these at a minimum, even if people can skip past them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems some users would like to do interactions more verbosely (see #6656). I still don't have an answer for it. But, as one of idea, it might be better to provide both silent and verbose way.

Note: silent means only "less". It does not equal to no question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. How about we make interactive not the default by adding an --interactive flag? With this flag, we would request all configuration options in an interactive manner from the user, but users that don't want to do this can simply pass the relevant args they care about, e.g. --project? That would satisfy the request of #6656 while not annoying people like you that just wants to start a really quick project? The other alternative is a combination of --quick (default) and --full arguments, with the latter enabling configuration of extensions etc. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer an option like --full. It is too much to choose non interactive mode by default to me. But it is annoying to me to list all configurations. I think it is difficult to choose to appropriate options or extensions for standard users. So it would be better to ask minimum configurations by default.

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.

3 participants