diff --git a/.cookiecutterrc b/.cookiecutterrc index 31476727..4d2465da 100644 --- a/.cookiecutterrc +++ b/.cookiecutterrc @@ -14,6 +14,7 @@ default_context: email: contact@ionelmc.ro formatter_quote_style: double full_name: Ionel Cristian Mărieș + function_name: compute github_actions: 'yes' github_actions_osx: 'yes' github_actions_windows: 'yes' diff --git a/docs/usage.rst b/docs/usage.rst index fb7ad6aa..7a5c904c 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -2,6 +2,10 @@ Usage ===== -To use Nameless in a project:: +To use the project: - import nameless + +.. code-block:: python + + import nameless + nameless.compute(...) diff --git a/src/nameless/__init__.py b/src/nameless/__init__.py index 9553db54..693f041b 100644 --- a/src/nameless/__init__.py +++ b/src/nameless/__init__.py @@ -1,7 +1,7 @@ __version__ = "0.1.0" -from .core import main +from .core import compute __all__ = [ - "main", + "compute", ] diff --git a/src/nameless/_core.c b/src/nameless/_core.c index d938fbad..b522d5c4 100644 --- a/src/nameless/_core.c +++ b/src/nameless/_core.c @@ -1,6 +1,6 @@ #include "Python.h" -static PyObject* main(PyObject *self, PyObject *value) { +static PyObject* compute(PyObject *self, PyObject *value) { PyObject *module; PyObject *module_dict; PyObject *len; @@ -47,10 +47,10 @@ static PyObject* main(PyObject *self, PyObject *value) { return result; } -PyDoc_STRVAR(main_doc, "Docstring for main function."); +PyDoc_STRVAR(compute_doc, "Docstring for compute function."); static struct PyMethodDef module_functions[] = { - {"main", main, METH_O, main_doc}, + {"compute", compute, METH_O, compute_doc}, {NULL, NULL} }; diff --git a/src/nameless/cli.py b/src/nameless/cli.py index 5b4358a1..114890c0 100644 --- a/src/nameless/cli.py +++ b/src/nameless/cli.py @@ -17,7 +17,7 @@ import argparse -from .core import main +from .core import compute parser = argparse.ArgumentParser(description="Command description.") parser.add_argument( @@ -30,5 +30,5 @@ def run(args=None): args = parser.parse_args(args=args) - print(main(args.names)) + print(compute(args.names)) parser.exit(0) diff --git a/src/nameless/core.py b/src/nameless/core.py index 86450b54..6354cc2c 100644 --- a/src/nameless/core.py +++ b/src/nameless/core.py @@ -1,6 +1,6 @@ try: - from ._core import main + from ._core import compute except ImportError: - def main(args): + def compute(args): return max(args, key=len) diff --git a/tests/test_core.py b/tests/test_core.py index b7c0516a..d809c2bc 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,5 +1,5 @@ -from nameless import main +from nameless import compute -def test_main(): - assert main(["a", "bc", "abc"]) == "abc" +def test_compute(): + assert compute(["a", "bc", "abc"]) == "abc"