Issue 1:
Issue Type:

Can you help us out in labelling this by telling us what kind of ticket this this? You can say “Bug Report”, “Feature Idea”, “Feature Pull Request”, “New Module Pull Request”, “Bugfix Pull Request”, “Documentation Report”, or “Docs Pull Request”.

Ansible Version:

# ansible-doc --version
ansible-doc 1.8 (devel 7d9661a266) last updated 2014/09/30 10:46:06 (GMT -400)
lib/ansible/modules/core: (detached HEAD db5668b84c) last updated 2014/09/29 11:27:31 (GMT -400)
lib/ansible/modules/extras: (detached HEAD 110250d344) last updated 2014/09/29 11:27:34 (GMT -400)
configured module search path = None

Environment:

Mac OSX

Summary:

The command ansible-doc -l emits tracebacks while scanning modules.

Steps To Reproduce:

. hacking/env-setup

ansible-doc -l

Expected Results:

No tracebacks on stderr

Actual Results:

﻿﻿# ansible-doc -l 1>/dev/null 2| pbcopy
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/lib/ansible/utils/module_docs.py", line 50, in get_docstring
M = ast.parse(''.join(open(filename)))
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
gitdir: ../../../../.git/modules/lib/ansible/modules/core
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module .git has a documentation error formatting or is missing documentation
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/lib/ansible/utils/module_docs.py", line 50, in get_docstring
M = ast.parse(''.join(open(filename)))
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 2
*.py[co]
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module .gitignore has a documentation error formatting or is missing documentation
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/lib/ansible/utils/module_docs.py", line 50, in get_docstring
M = ast.parse(''.join(open(filename)))
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
Welcome To Ansible GitHub
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module CONTRIBUTING.md has a documentation error formatting or is missing documentation
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/lib/ansible/utils/module_docs.py", line 50, in get_docstring
M = ast.parse(''.join(open(filename)))
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
GNU GENERAL PUBLIC LICENSE
^
IndentationError: unexpected indent
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module COPYING has a documentation error formatting or is missing documentation
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/lib/ansible/utils/module_docs.py", line 50, in get_docstring
M = ast.parse(''.join(open(filename)))
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 2
====================
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module README.md has a documentation error formatting or is missing documentation
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module __init__.py has a documentation error formatting or is missing documentation
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/lib/ansible/utils/module_docs.py", line 50, in get_docstring
M = ast.parse(''.join(open(filename)))
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
TypeError: compile() expected string without null bytes
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module __init__.pyc has a documentation error formatting or is missing documentation
Traceback (most recent call last):
File "/Users/jlaska/Downloads/ansible.git/bin/ansible-doc", line 184, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
ERROR: module async_wrapper.py has a documentation error formatting or is missing documentation

Issue 2:
Problem:

If you add a custom module using git submodules, ansible-doc prints traceback.

setup in ansible.cfg

we set up a path for custom modules:

[default]
library = /usr/share/ansible:library

custom modules added with submodules

we added a module named openvz using `git submodule add library/openvz

library$ find
.
./openvz
./openvz/.git
./openvz/openvz

content of .git

$ cat ./openvz/.git
gitdir: ../../../.git/modules/playbooks/library/openvz

error in run command ansible-doc

$ ansible-doc -l
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ansible/utils/module_docs.py", line 44, in get_docstring
M = ast.parse(''.join(open(filename)))
File "/usr/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
gitdir: ../../../.git/modules/playbooks/library/openvz
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/usr/local/bin/ansible-doc", line 174, in get_module_list_text
desc = tty_ify(doc.get('short_description', '?'))
AttributeError: 'NoneType' object has no attribute 'get'
...

ansible version

$ ansible --version
ansible 1.5

Expected

ansible-doc should ignore "hidden" directories.