Skip to content

Commit

Permalink
Added '--with-child-links' option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed May 2, 2014
1 parent 3006af6 commit 0cf6006
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -13,6 +13,7 @@ Changelog
- Changed '--no-rlink-check' to '--no-child-check'
- Added Item.find_child_items() and Item.find_child_documents()
- Added aliases to Item: parent_links, child_links/items/documents
- Added '--with-child-links' to 'doorstop publish' to publish child links

0.5 (2014/04/25)
----------------
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -103,9 +103,9 @@ apidocs/$(PACKAGE)/index.html: $(SOURCES)
html: env docs/gen/*.html
docs/gen/*.html: $(shell find . -name '*.yml')
- $(MAKE) doorstop
$(BIN)/doorstop publish all docs/gen --text --with-child-links
$(BIN)/doorstop publish all docs/gen --markdown --with-child-links
$(BIN)/doorstop publish all docs/gen --html --with-child-links
$(BIN)/doorstop publish all docs/gen --text
$(BIN)/doorstop publish all docs/gen --markdown
$(BIN)/doorstop publish all docs/gen --html

.PHONY: read
read: readme apidocs html
Expand Down
7 changes: 7 additions & 0 deletions doorstop/cli/main.py
Expand Up @@ -107,6 +107,8 @@ def main(args=None): # pylint: disable=R0915
help="output HTML (default for 'all')")
sub.add_argument('-w', '--width', type=int,
help="limit line width on text output")
sub.add_argument('-C', '--with-child-links', action='store_true',
help="include child links in published documents")

# Parse arguments
args = parser.parse_args(args=args)
Expand Down Expand Up @@ -336,6 +338,11 @@ def _run_publish(args, cwd, err):
@param err: function to call for CLI errors
"""
# Configure publishing settings
if args.with_child_links is not None:
settings.PUBLISH_CHILD_LINKS = args.with_child_links

# Build the tree to publish
publish_tree = args.prefix == 'all'
try:
tree = build(cwd, root=args.project)
Expand Down
12 changes: 12 additions & 0 deletions doorstop/cli/test/test_all.py
Expand Up @@ -258,10 +258,22 @@ class TestPublish(unittest.TestCase): # pylint: disable=R0904
def setUp(self):
self.cwd = os.getcwd()
self.temp = tempfile.mkdtemp()
self.backup = (settings.PUBLISH_CHILD_LINKS,)

def tearDown(self):
os.chdir(self.cwd)
shutil.rmtree(self.temp)
(settings.PUBLISH_CHILD_LINKS,) = self.backup

def test_publish(self):
"""Verify 'doorstop publish' can create output."""
self.assertIs(None, main(['publish', 'tut']))
self.assertFalse(settings.PUBLISH_CHILD_LINKS)

def test_publish_with_child_links(self):
"""Verify 'doorstop publish' can create output with child links."""
self.assertIs(None, main(['publish', 'tut', '--with-child-links']))
self.assertTrue(settings.PUBLISH_CHILD_LINKS)

def test_publish_error(self):
"""Verify 'doorstop publish' returns an error in an empty folder."""
Expand Down

0 comments on commit 0cf6006

Please sign in to comment.