Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ script:
- python doctests.py
# Run the type checker
- python run_mypy.py
# Check that all strategies are in the index
- python run_strategy_indexer.py
after_success:
- coveralls
notifications:
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/all_strategies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Here are the docstrings of all the strategies in the library.
.. automodule:: axelrod.strategies.handshake
:members:
:undoc-members:
.. automodule:: axelrod.strategies.hmm
:members:
:undoc-members:
.. automodule:: axelrod.strategies.hunter
:members:
:undoc-members:
Expand All @@ -93,6 +96,9 @@ Here are the docstrings of all the strategies in the library.
.. automodule:: axelrod.strategies.mathematicalconstants
:members:
:undoc-members:
.. automodule:: axelrod.strategies.memorytwo
:members:
:undoc-members:
.. automodule:: axelrod.strategies.memoryone
:members:
:undoc-members:
Expand Down
3 changes: 2 additions & 1 deletion run_mypy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
import sys
modules = ["axelrod/actions.py",
modules = ["run_strategy_indexer.py",
"axelrod/actions.py",
"axelrod/deterministic_cache.py",
"axelrod/ecosystem.py",
"axelrod/game.py",
Expand Down
49 changes: 49 additions & 0 deletions run_strategy_indexer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
A script to check that all strategy modules have been included in
`./docs/reference/all_strategies.rst`
"""
import sys
import pathlib

default_index_path = pathlib.Path("./docs/reference/all_strategies.rst")
excluded_modules = ("_strategies", "__init__", "_filters", "human")

def check_module(module_path: pathlib.Path,
index_path: pathlib.Path=default_index_path,
excluded: tuple=excluded_modules) -> bool:
"""
Check if a module name is written in the index of strategies.

Parameters
----------
module_path :
A file path for a module file.
index_path :
A file path for the index file where all strategies are auto documented
excluded :
A collection of module names to be ignored

Returns
-------
boolean :
True/False if module is referenced.

"""
strategies_index = index_path.read_text()
module_name = module_path.stem
if module_name not in excluded and module_name not in strategies_index:
print("{} not in index".format(module_name))
return False
return True


if __name__ == "__main__":

p = pathlib.Path('.')
modules = p.glob("./axelrod/strategies/*.py")
exit_codes = []

for module_path in modules:
exit_codes.append(int(not check_module(module_path)))

sys.exit(max(exit_codes))