Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch problems with text type #13393

Merged
merged 3 commits into from May 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/MooseDocs/base/lexers.py
Expand Up @@ -219,10 +219,14 @@ def tokenize(self, parent, text, page, grammar, line=1):
the entire text to be tokenized and have the errors report upon completion.
"""
if MooseDocs.LOG_LEVEL == logging.DEBUG:
common.check_type('text', text, unicode)
common.check_type('page', page, pages.Page)
common.check_type('line', line, int)

if not isinstance(text, unicode):
msg = "EXCEPTION: {}:{}\n{}".format(page.source, line,
"The supplied text must be unicode.")
raise TypeError(msg)

n = len(text)
pos = 0
while pos < n:
Expand Down
7 changes: 7 additions & 0 deletions python/MooseDocs/common/get_content.py
Expand Up @@ -10,6 +10,7 @@
#pylint: enable=missing-docstring
import os
import re
import copy
import logging
import mooseutils
import MooseDocs
Expand Down Expand Up @@ -106,6 +107,12 @@ def _doc_import(root_dir, content=None):
for pattern in exclude:
output -= _find_files(output, os.path.join(root_dir, pattern))

# Test the files exist
for fname in copy.copy(output):
if not os.path.isfile(fname):
LOG.error("Unknown file provided in content (it is being removed):\n%s", fname)
output.remove(fname)

return sorted(output)

def create_file_page(name, filename, in_ext):
Expand Down
7 changes: 0 additions & 7 deletions python/MooseDocs/test/unit/common/test_get_pages.py
Expand Up @@ -162,13 +162,6 @@ def testBasic(self):
self.assertEqual(p.source,
os.path.join(ROOT_DIR, 'framework/doc/content/getting_started'))

if p.name == 'getting_started/installation/bash_profile.md':
self.assertIsInstance(p, pages.Source)
self.assertEqual(p.local, 'getting_started/installation/bash_profile.md')
self.assertEqual(p.source,
os.path.join(ROOT_DIR,
'framework/doc/content/getting_started/installation/bash_profile.md'))

if __name__ == '__main__':
import logging
logging.basicConfig()
Expand Down