Skip to content

Commit

Permalink
Merge pull request #809 from ewels/lint-refactoring
Browse files Browse the repository at this point in the history
Lint refactoring
  • Loading branch information
ewels authored Dec 14, 2020
2 parents 4a11490 + 135fb8b commit 801bbf3
Show file tree
Hide file tree
Showing 108 changed files with 3,394 additions and 3,182 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ We aim to write function docstrings according to the [Google Python style-guide]
You can find this documentation here: [https://nf-co.re/tools-docs/](https://nf-co.re/tools-docs/)

If you would like to test the documentation, you can install Sphinx locally by following Sphinx's [installation instruction](https://www.sphinx-doc.org/en/master/usage/installation.html).
Once done, you can run `make clean` and then `make html` in the root directory of `nf-core tools`.
Once done, you can run `make clean` and then `make html` in the `docs/api` directory of `nf-core tools`.
The HTML will then be generated in `docs/api/_build/html`.

## Tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.coverage
.pytest_cache
docs/api/_build

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions docs/api/_src/api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
API Reference
=============

.. toctree::
:maxdepth: 2
:caption: Tests:
:glob:

*
2 changes: 1 addition & 1 deletion docs/api/_src/launch.rst → docs/api/_src/api/launch.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nf_core.launch
============
==============

.. automodule:: nf_core.launch
:members:
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions docs/api/_src/api/lint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
nf_core.lint
============

.. seealso:: See the `Lint Tests <../lint_tests/index.html>`_ docs for information about specific linting functions.

.. automodule:: nf_core.lint
:members: run_linting
:undoc-members:
:show-inheritance:

.. autoclass:: nf_core.lint.PipelineLint
:members: _lint_pipeline
:private-members: _print_results, _get_results_md, _save_json_results, _wrap_quotes, _strip_ansi_codes
:show-inheritance:
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nf_core.modules
============
===============

.. automodule:: nf_core.modules
:members:
Expand Down
2 changes: 1 addition & 1 deletion docs/api/_src/schema.rst → docs/api/_src/api/schema.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nf_core.schema
============
==============

.. automodule:: nf_core.schema
:members:
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion docs/api/_src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "nature"
# html_theme = "nature"
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
9 changes: 8 additions & 1 deletion docs/api/_src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ Welcome to nf-core tools API documentation!
===========================================

.. toctree::
:hidden:
:maxdepth: 2
:caption: Contents:
:glob:

*
lint_tests/index.rst
api/index.rst

This documentation is for the ``nf-core/tools`` package.

Primarily, it describes the different `code lint tests <lint_tests/index.html>`_
run by ``nf-core lint`` (typically visited by a developer when their pipeline fails a given
test), and also reference for the ``nf_core`` `Python package API <api/index.html>`_.

Indices and tables
==================
Expand Down
8 changes: 0 additions & 8 deletions docs/api/_src/lint.rst

This file was deleted.

4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/actions_awsfulltest.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions_awsfulltest
===================

.. automethod:: nf_core.lint.PipelineLint.actions_awsfulltest
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/actions_awstest.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions_awstest
===============

.. automethod:: nf_core.lint.PipelineLint.actions_awstest
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/actions_branch_protection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions_branch_protection
=========================

.. automethod:: nf_core.lint.PipelineLint.actions_branch_protection
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/actions_ci.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions_ci
==========

.. automethod:: nf_core.lint.PipelineLint.actions_ci
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/actions_lint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions_lint
============

.. automethod:: nf_core.lint.PipelineLint.actions_lint
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/conda_dockerfile.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
conda_dockerfile
================

.. automethod:: nf_core.lint.PipelineLint.conda_dockerfile
6 changes: 6 additions & 0 deletions docs/api/_src/lint_tests/conda_env_yaml.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
conda_env_yaml
==============

.. automethod:: nf_core.lint.PipelineLint.conda_env_yaml
.. automethod:: nf_core.lint.PipelineLint._anaconda_package
.. automethod:: nf_core.lint.PipelineLint._pip_package
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/cookiecutter_strings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cookiecutter_strings
====================

.. automethod:: nf_core.lint.PipelineLint.cookiecutter_strings
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/files_exist.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files_exist
===========

.. automethod:: nf_core.lint.PipelineLint.files_exist
9 changes: 9 additions & 0 deletions docs/api/_src/lint_tests/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Lint tests
============================================

.. toctree::
:maxdepth: 2
:caption: Tests:
:glob:

*
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/licence.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
licence
=======

.. automethod:: nf_core.lint.PipelineLint.licence
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/nextflow_config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nextflow_config
===============

.. automethod:: nf_core.lint.PipelineLint.nextflow_config
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/pipeline_name_conventions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pipeline_name_conventions
=========================

.. automethod:: nf_core.lint.PipelineLint.pipeline_name_conventions
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/pipeline_todos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pipeline_todos
==============

.. automethod:: nf_core.lint.PipelineLint.pipeline_todos
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
readme
======

.. automethod:: nf_core.lint.PipelineLint.readme
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/schema_lint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
schema_lint
===========

.. automethod:: nf_core.lint.PipelineLint.schema_lint
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/schema_params.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
schema_params
=============

.. automethod:: nf_core.lint.PipelineLint.schema_params
4 changes: 4 additions & 0 deletions docs/api/_src/lint_tests/version_consistency.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version_consistency
===================

.. automethod:: nf_core.lint.PipelineLint.version_consistency
32 changes: 32 additions & 0 deletions docs/api/make_lint_rst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python

import fnmatch
import os
import nf_core.lint

docs_basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "_src", "lint_tests")

# Get list of existing .rst files
existing_docs = []
for fn in os.listdir(docs_basedir):
if fnmatch.fnmatch(fn, "*.rst") and not fnmatch.fnmatch(fn, "index.rst"):
existing_docs.append(os.path.join(docs_basedir, fn))

# Make .rst file for each test name
lint_obj = nf_core.lint.PipelineLint("", True)
rst_template = """{0}
{1}
.. automethod:: nf_core.lint.PipelineLint.{0}
"""

for test_name in lint_obj.lint_tests:
fn = os.path.join(docs_basedir, "{}.rst".format(test_name))
if os.path.exists(fn):
existing_docs.remove(fn)
else:
with open(fn, "w") as fh:
fh.write(rst_template.format(test_name, len(test_name) * "="))

for fn in existing_docs:
os.remove(fn)
2 changes: 2 additions & 0 deletions docs/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sphinx>=3.3.1
sphinx_rtd_theme>=0.5.0
Loading

0 comments on commit 801bbf3

Please sign in to comment.