Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This will create the `poetry-demo` directory with the following content:
```text
poetry-demo
├── pyproject.toml
├── README.rst
├── README.md
├── poetry_demo
│ └── __init__.py
└── tests
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ will create a folder as follows:
```text
my-package
├── pyproject.toml
├── README.rst
├── README.md
├── my_package
│ └── __init__.py
└── tests
Expand All @@ -65,7 +65,7 @@ That will create a folder structure as follows:
```text
my-package
├── pyproject.toml
├── README.rst
├── README.md
├── src
│ └── my_package
│ └── __init__.py
Expand Down
8 changes: 8 additions & 0 deletions poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class InitCommand(Command):
init
{--name= : Name of the package}
{--description= : Description of the package}
{--readme= : Readme file of the package}
{--author= : Author name of the package}
{--dependency=* : Package to require with an optional version constraint,
e.g. requests:^2.10.0 or requests=2.11.1}
Expand Down Expand Up @@ -76,6 +77,12 @@ def handle(self):
)
description = self.ask(question)

readme = self.option("readme") or ""
question = self.create_question(
"Readme [<comment>{}</comment>]: ".format(readme), default=readme
)
readme = self.ask(question)

author = self.option("author")
if not author and vcs_config and vcs_config.get("user.name"):
author = vcs_config["user.name"]
Expand Down Expand Up @@ -141,6 +148,7 @@ def handle(self):
name,
version,
description=description,
readme=readme,
author=authors[0] if authors else None,
license=license,
python=python,
Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def handle(self):
"exists and is not empty".format(path)
)

readme_format = "rst"
readme_format = "md"

config = GitConfig()
author = None
Expand Down
27 changes: 19 additions & 8 deletions poetry/layouts/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(
project,
version="0.1.0",
description="",
readme=None,
readme_format="md",
author=None,
license=None,
Expand All @@ -59,6 +60,7 @@ def __init__(
self._package_name = module_name(project)
self._version = version
self._description = description
self._readme = readme
self._readme_format = readme_format
self._license = license
self._python = python
Expand All @@ -73,11 +75,11 @@ def __init__(

self._author = author

def create(self, path, with_tests=True):
def create(self, path, with_tests=True, readme_format="md"):
path.mkdir(parents=True, exist_ok=True)

self._create_default(path)
self._create_readme(path)
self._create_readme(path, readme_format)

if with_tests:
self._create_tests(path)
Expand All @@ -94,6 +96,10 @@ def generate_poetry_content(self):
poetry_content["name"] = self._project
poetry_content["version"] = self._version
poetry_content["description"] = self._description

if self._readme:
poetry_content["readme"] = self._readme

poetry_content["authors"].append(self._author)
if self._license:
poetry_content["license"] = self._license
Expand Down Expand Up @@ -122,13 +128,18 @@ def generate_poetry_content(self):
def _create_default(self, path, src=True):
raise NotImplementedError()

def _create_readme(self, path):
if self._readme_format == "rst":
readme_file = path / "README.rst"
else:
readme_file = path / "README.md"
def _create_readme(self, path, readme_format):
readme_file = path / "README.{}".format(self._readme_format)

with open(readme_file, "w") as f:
if readme_format == "md":
f.write("# {}".format(self._project))
elif readme_format == "rst":
f.write("=" * len(self._project))
f.write("# {}".format(self._project))
f.write("=" * len(self._project))

readme_file.touch()
self._readme = readme_file

def _create_tests(self, path):
self._dev_dependencies["pytest"] = "^3.0"
Expand Down