{{ message }}
feat: default project_directory to current dir in mkdocs new#4090
Open
Gdhanush-13 wants to merge 2 commits into
Open
feat: default project_directory to current dir in mkdocs new#4090Gdhanush-13 wants to merge 2 commits into
mkdocs new#4090Gdhanush-13 wants to merge 2 commits into
Conversation
When running mkdocs new without specifying a project directory, default to the current directory (.) instead of raising an error. This makes mkdocs new behave identically to mkdocs new ., reducing friction for users who want to initialize a project in their current working directory. Fixes mkdocs#1988
Signed-off-by: Gdhanush_13 <dhanushdhanu1300@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
When running
mkdocs newwithout specifying a project directory, the command currently raises an error becauseproject_directoryis a required argument. This PR makes the argument optional by defaulting to'.'(the current working directory), somkdocs newbehaves identically tomkdocs new ..This is a small quality-of-life improvement that reduces friction for users who want to initialize a project in their current directory.
Changes
mkdocs/__main__.py: Addeddefault='.'to theproject_directoryclick argument.mkdocs/tests/cli_tests.py: Addedtest_new_defaultto verify the CLI defaults to'.'when no argument is provided.mkdocs/tests/new_tests.py: Addedtest_new_current_dirto verifynew('.')correctly createsmkdocs.ymlanddocs/index.mdin the current directory.Motivation
Closes #1988
As noted in the issue, running
mkdocs newwithout a path should default to'.'rather than requiring the user to explicitly typemkdocs new .. This matches the behavior of similar CLI tools (e.g.,git init,npm init) that default to the current directory.