Skip to content

Commit

Permalink
Added tree structure to the index.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jun 27, 2014
1 parent 4ef11b3 commit 5b71e4d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
37 changes: 30 additions & 7 deletions doorstop/core/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,37 @@ def _lines_index(filenames, charset='UTF-8', tree=None):
yield '</style>'
yield '</head>'
yield '<body>'
yield '<div align="center">'
for filename in filenames:
name = os.path.splitext(filename)[0]
yield '<li> <a href="{f}">{n}</a> </li>'.format(f=filename, n=name)
yield '</div>'
# Tree structure
text = tree.draw() if tree else None
if text:
yield ''
yield '<h3>Tree Structure:</h3>'
yield '<pre><code>' + text + '</pre></code>'
# Additional files
if filenames:
if text:
yield ''
yield '<hr>'
yield ''
yield '<h3>Published Documents:</h3>'
yield '<p>'
yield '<ul>'
for filename in filenames:
name = os.path.splitext(filename)[0]
yield '<li> <a href="{f}">{n}</a> </li>'.format(f=filename, n=name)
yield '</ul>'
yield '</p>'
# Traceability table
documents = tree.documents if tree else None
if documents:
yield '<br> <br>'
if text or filenames:
yield ''
yield '<hr>'
yield ''
# table
yield '<table align="center">'
yield '<h3>Item Traceability:</h3>'
yield '<p>'
yield '<table>'
# header
for document in documents:
yield '<col width="100">'
Expand All @@ -133,7 +154,9 @@ def _lines_index(filenames, charset='UTF-8', tree=None):
# data
# TODO: add table data
yield '</table>'
yield '</p>'

yield ''
yield '</body>'
yield '</html>'

Expand Down
9 changes: 7 additions & 2 deletions doorstop/core/test/files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,15 @@
</style>
</head>
<body>
<div align="center">

<h3>Published Documents:</h3>
<p>
<ul>
<li> <a href="index2.html">index2</a> </li>
<li> <a href="published.html">published</a> </li>
<li> <a href="published2.html">published2</a> </li>
</div>
</ul>
</p>

</body>
</html>
23 changes: 19 additions & 4 deletions doorstop/core/test/files/index2.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,26 @@
</style>
</head>
<body>
<div align="center">

<h3>Tree Structure:</h3>
<pre><code>(mock tree structure)</pre></code>

<hr>

<h3>Published Documents:</h3>
<p>
<ul>
<li> <a href="index2.html">index2</a> </li>
<li> <a href="published.html">published</a> </li>
<li> <a href="published2.html">published2</a> </li>
</div>
<br> <br>
<table align="center">
</ul>
</p>

<hr>

<h3>Item Traceability:</h3>
<p>
<table>
<col width="100">
<col width="100">
<col width="100">
Expand All @@ -238,5 +251,7 @@
<td height="25" align="center"> <a href="LLT.html">LLT</a> </td>
</tr>
</table>
</p>

</body>
</html>
1 change: 1 addition & 0 deletions doorstop/core/test/test_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def test_index_tree(self):
mock_document = Mock()
mock_document.prefix = prefix
mock_tree.documents.append(mock_document)
mock_tree.draw = lambda: "(mock tree structure)"
# Act
publisher._index(FILES, index="index2.html", tree=mock_tree) # pylint: disable=W0212
# Assert
Expand Down

0 comments on commit 5b71e4d

Please sign in to comment.