mofmt


Namemofmt JSON
Version 0.3.6 PyPI version JSON
download
home_pagehttps://github.com/ErykMroczek/mofmt
SummaryModelica Code Formatter
upload_time2024-01-09 14:29:15
maintainer
docs_urlNone
authorEryk Mroczek
requires_python>=3.9,<4.0
licenseMIT
keywords modelica automation formatter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mofmt - Modelica code formatter

*Mofmt* is a code formatter for [Modelica](https://modelica.org/)
language. It aims to enhance readability and provide style constistency
across different Modelica projects.

Although functionality is basically finished, it can of course exhibit
buggy behavior. *mofmt* doesn't modify files if it meets syntax errors.
I advice to double-check changed files.

Code style applied by the *mofmt* is described in `code-style.md`.

## Installation and usage

### Installation

*Mofmt* can be installed from PYPI:

```shell
pip install mofmt
```

On top of that, repo contains a necessary `pre-commit-hooks.yaml` file,
so if you are using Git, you can delegate running *mofmt* to
[pre-commit](https://pre-commit.com/) framework.

### Usage

*mofmt* takes one kind of argument - path that points to Modelica source
file or directory that is supposed to contain such files. *mofmt* can
accept multiple such arguments.

```shell
mofmt PATH ...
```

## Features and limitations

### Vertical spacing and grouping

*Mofmt* aims to ensure that Modelica code is vertically grouped and
indented in a intuitive way that additionally allows you to fold/unfold
specific sections in your text editor. Yet it will try to preserve
single blank lines that you have placed manually, unless they were
placed in places that *mofmt* considers prohibited.

### Comments

Modelica language specification allows you to place comments between any
lexical units, but at least some software doesn't respect that and
displace your comments if it feels like it. *Mofmt* tries to avoid that
(but bugs may happen!). Both comments and whitespaces between them are
preserved. Additionally, *mofmt* preceeds your inline comments with a
single space to enhance readability.

### Line wrapping

*Mofmt* doesn't have a notion of maximum line length and doesn't wrap
lines automatically. This is a deliberate choice, for many expressions
in Modelica are written in a way that resembles textbook formulas. Such
formulas contain terms that have a specific meaning and probably are
kept on the same line by Modelica developers. Any (reasonably simple)
algorithm would probably be too stupid for that, so there is no wrapping
algorithm in *mofmt*. Instead, it will respect your wrapping inside
expressions (provided you wrapped at some operator):

```modelica
Q_flow = alpha * surfaceArea *
(T_a - T_b);
```

and only adjust it slightly:

```modelica
Q_flow = alpha * surfaceArea
  * (T_a - T_b);
```

If wrap is placed inside function call, array etc.:

```modelica
cp = specificHeat_pT(p = p, T = temperature_ph(p = p,
h = h));
```

*mofmt* will ensure that the whole argument list is formatted
consistently, including nested calls:

```modelica
cp = specificHeat_pT(
  p = p,
  T = temperature_ph(
    p = p,
    h = h));
```

## TODO

* improve parsing performance
* (maybe) include HTML pretty-printer

## License

MIT

## Authors

Eryk Mroczek: <mroczek.eryk@gmail.com>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ErykMroczek/mofmt",
    "name": "mofmt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "Modelica,automation,formatter",
    "author": "Eryk Mroczek",
    "author_email": "mroczek.eryk@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/42/8e/0aadb8a563181b408363c1d013087241cc8ec5a87b486ce72ade766d0838/mofmt-0.3.6.tar.gz",
    "platform": null,
    "description": "# mofmt - Modelica code formatter\n\n*Mofmt* is a code formatter for [Modelica](https://modelica.org/)\nlanguage. It aims to enhance readability and provide style constistency\nacross different Modelica projects.\n\nAlthough functionality is basically finished, it can of course exhibit\nbuggy behavior. *mofmt* doesn't modify files if it meets syntax errors.\nI advice to double-check changed files.\n\nCode style applied by the *mofmt* is described in `code-style.md`.\n\n## Installation and usage\n\n### Installation\n\n*Mofmt* can be installed from PYPI:\n\n```shell\npip install mofmt\n```\n\nOn top of that, repo contains a necessary `pre-commit-hooks.yaml` file,\nso if you are using Git, you can delegate running *mofmt* to\n[pre-commit](https://pre-commit.com/) framework.\n\n### Usage\n\n*mofmt* takes one kind of argument - path that points to Modelica source\nfile or directory that is supposed to contain such files. *mofmt* can\naccept multiple such arguments.\n\n```shell\nmofmt PATH ...\n```\n\n## Features and limitations\n\n### Vertical spacing and grouping\n\n*Mofmt* aims to ensure that Modelica code is vertically grouped and\nindented in a intuitive way that additionally allows you to fold/unfold\nspecific sections in your text editor. Yet it will try to preserve\nsingle blank lines that you have placed manually, unless they were\nplaced in places that *mofmt* considers prohibited.\n\n### Comments\n\nModelica language specification allows you to place comments between any\nlexical units, but at least some software doesn't respect that and\ndisplace your comments if it feels like it. *Mofmt* tries to avoid that\n(but bugs may happen!). Both comments and whitespaces between them are\npreserved. Additionally, *mofmt* preceeds your inline comments with a\nsingle space to enhance readability.\n\n### Line wrapping\n\n*Mofmt* doesn't have a notion of maximum line length and doesn't wrap\nlines automatically. This is a deliberate choice, for many expressions\nin Modelica are written in a way that resembles textbook formulas. Such\nformulas contain terms that have a specific meaning and probably are\nkept on the same line by Modelica developers. Any (reasonably simple)\nalgorithm would probably be too stupid for that, so there is no wrapping\nalgorithm in *mofmt*. Instead, it will respect your wrapping inside\nexpressions (provided you wrapped at some operator):\n\n```modelica\nQ_flow = alpha * surfaceArea *\n(T_a - T_b);\n```\n\nand only adjust it slightly:\n\n```modelica\nQ_flow = alpha * surfaceArea\n  * (T_a - T_b);\n```\n\nIf wrap is placed inside function call, array etc.:\n\n```modelica\ncp = specificHeat_pT(p = p, T = temperature_ph(p = p,\nh = h));\n```\n\n*mofmt* will ensure that the whole argument list is formatted\nconsistently, including nested calls:\n\n```modelica\ncp = specificHeat_pT(\n  p = p,\n  T = temperature_ph(\n    p = p,\n    h = h));\n```\n\n## TODO\n\n* improve parsing performance\n* (maybe) include HTML pretty-printer\n\n## License\n\nMIT\n\n## Authors\n\nEryk Mroczek: <mroczek.eryk@gmail.com>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Modelica Code Formatter",
    "version": "0.3.6",
    "project_urls": {
        "Homepage": "https://github.com/ErykMroczek/mofmt",
        "Repository": "https://github.com/ErykMroczek/mofmt",
        "changelog": "https://github.com/ErykMroczek/mofmt/blob/main/CHANGELOG.md"
    },
    "split_keywords": [
        "modelica",
        "automation",
        "formatter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "26bf3c146037211e5961e7feb83578edae165d6a600f90e770b45101d5fc1d28",
                "md5": "dab542b1914d553a8a456990bd8ea2cd",
                "sha256": "c55d8cacb4a5e3600d9e87a5145fb52220473351cb5a4821dac05574699a8c93"
            },
            "downloads": -1,
            "filename": "mofmt-0.3.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dab542b1914d553a8a456990bd8ea2cd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 77762,
            "upload_time": "2024-01-09T14:29:12",
            "upload_time_iso_8601": "2024-01-09T14:29:12.929543Z",
            "url": "https://files.pythonhosted.org/packages/26/bf/3c146037211e5961e7feb83578edae165d6a600f90e770b45101d5fc1d28/mofmt-0.3.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "428e0aadb8a563181b408363c1d013087241cc8ec5a87b486ce72ade766d0838",
                "md5": "a7fb41cb68adf4143e0d2902107a2f10",
                "sha256": "fcb3065017a927ee55ff6b8deb738fdb9c8bedea06e41e8ca3e2939b6ba3f25e"
            },
            "downloads": -1,
            "filename": "mofmt-0.3.6.tar.gz",
            "has_sig": false,
            "md5_digest": "a7fb41cb68adf4143e0d2902107a2f10",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 72827,
            "upload_time": "2024-01-09T14:29:15",
            "upload_time_iso_8601": "2024-01-09T14:29:15.080008Z",
            "url": "https://files.pythonhosted.org/packages/42/8e/0aadb8a563181b408363c1d013087241cc8ec5a87b486ce72ade766d0838/mofmt-0.3.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-09 14:29:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ErykMroczek",
    "github_project": "mofmt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "mofmt"
}
        
Elapsed time: 0.15872s