Beispiel #1
0
    def test_headers_ignored_if_compiled_project(self):
        with open("settings.yml", "w+") as settings_file:
            settings = {
                "headers": {
                    "section": False,
                    "chapter": False,
                    "sub_chapter": False
                }
            }
            settings_file.write(yaml.dump(settings))

        outliner = Outliner()
        outliner.compile_project(draft=True)

        gatsby = open("Gatsby.md", "r")
        text = gatsby.read()
        gatsby.close()
        os.remove("Gatsby.md")
        os.remove("Gatsby.html")

        self.assertEqual(
            text,
            "# Gatsby\n\n<br>\n\n<br>\n\n<br>\n\n<br>\n\n**01-Scene 1.md**: the _world_ beckons!\n\n<br>\n\n**02-Scene 2.md**: the _world_ beckons!\n\n<br>\n\n<br>\n\n"
        )

        os.remove("settings.yml")
Beispiel #2
0
    def test_outline_unaffected_by_header_settings(self):
        with open("settings.yml", "w+") as settings_file:
            settings = {
                "headers": {
                    "section": False,
                    "chapter": False,
                    "sub_chapter": False
                }
            }
            settings_file.write(yaml.dump(settings))

        outliner = Outliner()
        outliner.compile_project(draft=False)

        gatsby = open("outline.md", "r")
        text = gatsby.read()
        gatsby.close()
        os.remove("outline.md")
        os.remove("outline.html")
        os.remove("settings.yml")

        self.assertEqual(
            text,
            "# Gatsby\n\n## Part 1\n\n## Part 2\n\n### Chapter 1\n\n#### SubChapter 1\n\n**Scene 1**: This is an outline\n\n**Scene 2**\n\n### Chapter 2\n\n"
        )
Beispiel #3
0
    def test_compiles_project(self):
        outliner = Outliner()
        outliner.compile_project(draft=True)

        gatsby = open("Gatsby.md", "r")
        text = gatsby.read()
        gatsby.close()
        os.remove("Gatsby.md")
        os.remove("Gatsby.html")

        self.assertEqual(
            text,
            "# Gatsby\n\n## Part 1\n\n## Part 2\n\n### Chapter 1\n\n#### SubChapter 1\n\n**01-Scene 1.md**: the _world_ beckons!\n\n<br>\n\n**02-Scene 2.md**: the _world_ beckons!\n\n<br>\n\n### Chapter 2\n\n"
        )
Beispiel #4
0
    def test_creates_outline(self):
        outliner = Outliner()
        outliner.compile_project(draft=False)

        gatsby = open("outline.md", "r")
        text = gatsby.read()
        gatsby.close()
        os.remove("outline.md")

        self.assertEqual(
            text,
            "# Gatsby\n\n## Part 1\n\n## Part 2\n\n### Chapter 1\n\n#### SubChapter 1\n\n**Scene 1**: This is an outline\n\n**Scene 2**\n\n### Chapter 2\n\n"
        )

        gatsby = open("outline.html", "r")
        text = gatsby.read()
        gatsby.close()
        os.remove("outline.html")
Beispiel #5
0
    def test_includes_author(self):
        with open("settings.yml", "w+") as settings_file:
            settings = {"author": "Garrett Edel"}
            settings_file.write(yaml.dump(settings))

        outliner = Outliner()
        outliner.compile_project(draft=True)

        gatsby = open("Gatsby.md", "r")
        text = gatsby.read()
        gatsby.close()
        os.remove("Gatsby.md")
        os.remove("Gatsby.html")
        os.remove("settings.yml")

        self.assertEqual(
            text,
            "# Gatsby\n\n##### Garrett Edel\n\n## Part 1\n\n## Part 2\n\n### Chapter 1\n\n#### SubChapter 1\n\n**01-Scene 1.md**: the _world_ beckons!\n\n<br>\n\n**02-Scene 2.md**: the _world_ beckons!\n\n<br>\n\n### Chapter 2\n\n"
        )
Beispiel #6
0
    def test_increments_outline_if_exists(self):
        with open("outline.md", "w") as outline:
            outline.write("whatever")
        with open("2-outline.md", "w") as outline:
            outline.write("whatever")

        outliner = Outliner()
        outliner.compile_project(draft=False)

        gatsby = open("3-outline.md", "r")
        text = gatsby.read()
        gatsby.close()

        self.assertTrue(os.path.exists("2-outline.md"))
        self.assertEqual(
            text,
            "# Gatsby\n\n## Part 1\n\n## Part 2\n\n### Chapter 1\n\n#### SubChapter 1\n\n**Scene 1**: This is an outline\n\n**Scene 2**\n\n### Chapter 2\n\n"
        )
        os.remove("2-outline.md")
        os.remove("3-outline.md")
        os.remove("outline.md")
        os.remove("outline.html")
Beispiel #7
0
def compile():
    """Compiles the project into markdown and HTML documents.

    Usage:
      >>> draft compile

    """
    generator = Generator()
    generator.confirm_project_layout()

    outliner = Outliner()
    filename = outliner.compile_project(draft=True)

    click.secho("Project compiled at " + filename + ".", fg="green")
Beispiel #8
0
def outline():
    """Generates a new project outline.

    Usage:
      >>> draft outline

    """
    generator = Generator()
    generator.confirm_project_layout()

    outliner = Outliner()
    filename = outliner.compile_project()

    click.secho("Project outlined at " + filename + ".", fg="green")
Beispiel #9
0
    def test_headers_overridden(self):
        with open("settings.yml", "w+") as settings_file:
            settings = {
                "overrides": {
                    "Gatsby": "The Great Gatsby",
                    "Chapter 1": "Chapter 1: Word",
                }
            }
            settings_file.write(yaml.dump(settings))

        outliner = Outliner()
        outliner.compile_project(draft=True)

        gatsby = open("Gatsby.md", "r")
        text = gatsby.read()
        gatsby.close()
        os.remove("Gatsby.md")
        os.remove("Gatsby.html")
        os.remove("settings.yml")

        self.assertEqual(
            text,
            "# The Great Gatsby\n\n## Part 1\n\n## Part 2\n\n### Chapter 1: Word\n\n#### SubChapter 1\n\n**01-Scene 1.md**: the _world_ beckons!\n\n<br>\n\n**02-Scene 2.md**: the _world_ beckons!\n\n<br>\n\n### Chapter 2\n\n"
        )