Commit 3d2c1e7f authored by Anton Smirnov's avatar Anton Smirnov
Browse files

Docs

parent 6c312bc7
Loading
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<a class="sidebar-brand{% if logo %} centered{% endif %}" href="{{ pathto(master_doc) }}">
    {% block brand_content %}
    {%- if logo %}
    <div class="sidebar-logo-container">
        <img class="sidebar-logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/>
    </div>
    {%- endif %}
    {%- if theme_light_logo and theme_dark_logo %}
    <div class="sidebar-logo-container">
        <img class="sidebar-logo only-light" src="{{ pathto('_static/' + theme_light_logo, 1) }}" alt="Light Logo"/>
        <img class="sidebar-logo only-dark" src="{{ pathto('_static/' + theme_dark_logo, 1) }}" alt="Dark Logo"/>
    </div>
    {%- endif %}
    {% if not theme_sidebar_hide_name %}
    <span class="sidebar-brand-text">{{ docstitle }}</span>
    {%- endif %}
    {% endblock brand_content %}
</a>

{%- if current_version -%}
    <div class="sidebar-brand">{{ current_version }}</div>
{%- endif -%}

docs/calculator.rst

0 → 100644
+20 −0
Original line number Diff line number Diff line
Calculator
##########

``Arokettu\ArithmeticParser\Calculator`` class is used to interpret the arithmetic expression.


``Calculator::parse()``
=======================

Parses the expression and creates an instance of calculator for it.

``calc()``
==========

Evaluates the expression with given variables (if any).

``Calculator::evaluate()``
==========================

``Calculator::evaluate($expression, ...$vars)`` is a shorthand for ``Calculator::parse($expression)->calc(...$vars)``

docs/conf.py

0 → 100644
+10 −0
Original line number Diff line number Diff line
from datetime import datetime

project = 'Arithmetic Parser'
author = 'Anton Smirnov'
copyright = '{} {}'.format(datetime.now().year, author)
language = 'en'

html_title = project
html_theme = 'furo'
templates_path = ["_templates"]

docs/config.rst

0 → 100644
+65 −0
Original line number Diff line number Diff line
Configuration
#############

``Arokettu\ArithmeticParser\Config`` and ``Arokettu\ArithmeticParser\ConfigBuilder``
classes are used to configure the calculator and the parser (in future).

Config is an immutable object and ConfigBuilder is a user-friendly way to set up options.

ConfigBuilder
=============

``build()``
-----------

A method to create a Config object with configured parameters.

``ConfigBuilder::default()``
----------------------------

The default preset used when no config is specified.

``ConfigBuilder::defaultConfig()``
----------------------------------

A prebuilt instance of the Config object for the default preset.
A shortcut for ``ConfigBuilder::default()->build()`` with a cached instance.

Functions
=========

The only configurable thing for now is a set of functions.
The function must be a callable that accepts a single float argument.

Default functions:
`abs <https://www.php.net/manual/en/function.abs.php>`__,
`exp <https://www.php.net/manual/en/function.exp.php>`__,
`log <https://www.php.net/manual/en/function.log.php>`__,
`log10 <https://www.php.net/manual/en/function.log10.php>`__,
`sqrt <https://www.php.net/manual/en/function.sqrt.php>`__,
`acos <https://www.php.net/manual/en/function.acos.php>`__,
`asin <https://www.php.net/manual/en/function.asin.php>`__,
`atan <https://www.php.net/manual/en/function.atan.php>`__,
`cos <https://www.php.net/manual/en/function.cos.php>`__,
`sin <https://www.php.net/manual/en/function.sin.php>`__,
`tan <https://www.php.net/manual/en/function.tan.php>`__,
`acosh <https://www.php.net/manual/en/function.acosh.php>`__,
`asinh <https://www.php.net/manual/en/function.asinh.php>`__,
`atanh <https://www.php.net/manual/en/function.atanh.php>`__,
`cosh <https://www.php.net/manual/en/function.cosh.php>`__,
`sinh <https://www.php.net/manual/en/function.sinh.php>`__,
`tanh <https://www.php.net/manual/en/function.tanh.php>`__,
`ceil <https://www.php.net/manual/en/function.ceil.php>`__,
`floor <https://www.php.net/manual/en/function.floor.php>`__,
`round <https://www.php.net/manual/en/function.round.php>`__,
`deg2rad <https://www.php.net/manual/en/function.deg2rad.php>`__,
`rad2deg <https://www.php.net/manual/en/function.rad2deg.php>`__.

You can:

* Replace functions with your own list:
  ``$builder->setFunctions(['myfunc2' => fn ($a) => a ** 2]);``
* Add new functions:
  ``$builder->addFunctions(['myfunc3' => fn ($a) => a ** 3]);``
* Remove functions:
  ``$builder->removeFunctions('acos', 'asin');``

docs/expressions.rst

0 → 100644
+26 −0
Original line number Diff line number Diff line
Expressions
###########

Supported Elements
==================

Supported expressions can include:

* Unary ``+`` and ``-``.
* Binary ``+``, ``-``, ``*``, ``/``.
* Numbers, obviously.
  All numbers are cast to float internally.
* Functions.
  Function names are case insensitive alphanumeric strings that do not start with a number.
  Functions accept a single parameter.
  Custom functions can be created with a Config object.
* Variables.
  Variable names are case insensitive alphanumeric strings that do not start with a number.
  They may have an optional ``$`` prefix.
  Variables with and without prefix are equivalent.
  Also a variable can share its name with a function without collision.

Example
=======

``'sin(x) * (coef1 + coef2)'``
Loading