mermaidmro


Namemermaidmro JSON
Version 0.2.1 PyPI version JSON
download
home_page
SummaryCreate mermaid graphs from the method resolution order (mro) of Python objects.
upload_time2023-11-23 12:23:37
maintainer
docs_urlNone
author
requires_python>=3.7
licenseCopyright (c) 2023, Marcel Rieger All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords mro graph inheritance mermaid dag
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mermaidmro

<!-- marker-before-badges -->

[![Build status](https://github.com/riga/mermaidmro/actions/workflows/lint_and_test.yml/badge.svg)](https://github.com/riga/mermaidmro/actions/workflows/lint_and_test.yml)
[![Package version](https://img.shields.io/pypi/v/mermaidmro.svg?style=flat)](https://pypi.python.org/pypi/mermaidmro)
[![Python version](https://img.shields.io/badge/Python-%E2%89%A53.7-blue)](https://pypi.python.org/pypi/mermaidmro)
[![Documentation status](https://readthedocs.org/projects/mermaidmro/badge/?version=latest)](http://mermaidmro.readthedocs.io)
[![Code coverge](https://codecov.io/gh/riga/mermaidmro/graph/badge.svg?token=UAKGC13BVI)](https://codecov.io/gh/riga/mermaidmro)
[![License](https://img.shields.io/github/license/riga/mermaidmro.svg)](https://github.com/riga/mermaidmro/blob/master/LICENSE)

<!-- marker-after-badges -->

Create mermaid graphs from the method resolution order (mro) of Python objects.


<!-- marker-before-content -->

## CLI Examples

For the examples below, let's consider the following classes saved in a file `code.py` that can be imported via `import code` (adjust your `PYTHONPATH` if this is not the case).

```python
# code.py

class A(object):
    pass

class B(object):
    pass

class C(A):
    pass

class D(C, B):
    pass
```

### Generate mermaid text

Simply pass the module and class in the format `module_name:class_name` to `mermaidmro`.

```shell
> mermaidmro code:D

graph TD
    code.D("code.D (0)")
    code.C("code.C (1)")
    code.A("code.A (2)")
    code.B("code.B (3)")
    object("object (4)")

    code.C --> code.D
    code.B --> code.D
    code.A --> code.C
    object --> code.B
    object --> code.A
```

You can hide the mro indices by adding `--no-mro / -n`.

```shell
> mermaidmro code:D --no-mro

graph TD
    code.C --> code.D
    code.B --> code.D
    code.A --> code.C
    object --> code.B
    object --> code.A
```

You can also limit the maximum depth via `--max-depth / -m`.

```shell
> mermaidmro code:D --no-mro --max-depth 1

graph TD
    code.A --> code.D
    code.B --> code.D
```


### Open the graph in your browser

Just configure the executable of your browser you like to open the graph with via `--cmd / -c` (on Macs this is usually just `open`).
This functionality is based on the [mermaid.live](https://mermaid.live) service.

```shell
> mermaidmro code:D --cmd open

# opens https://mermaid.ink/img/pako:eNptkM8KwjAMh18l5JSBE_-dPAht9wgec6lbdYrdZNTT2LvbUUvLWE6_fB8kISPWfWPwDPgY9KeFa8Ud-JrptiLGEIB2BWORORWdAtovnIhOAB0WTkYngY7J9beXqZ13IQCdgss3Qlle_oflA9exSFjlKxKW61jgBtCawepnM_9lZHStsYZ9w9iYu_6-HeOE0w_Nr1i5?type=png
```

To open the graph in the live editor, add `--edit`.


### Visualize the graph in your terminal

This requires that you have a tool installed that lets you visualize images in your terminal, e.g. [`imgcat`](https://iterm2.com/documentation-images.html) for [iTerm2](https://iterm2.com).

```shell
> mermaidmro code:D --visualize imgcat

# shows
```

![code:D graph](https://media.githubusercontent.com/media/riga/mermaidmro/master/assets/graph.png)


### Download the graph

```shell
> mermaidmro code:D --download graph.png
```


## Installation

Simply install via [pip](https://pypi.python.org/pypi/mermaidmro)

```bash
pip install mermaidmro
```


## Development

- Source hosted at [GitHub](https://github.com/riga/mermaidmro)
- Report issues, questions, feature requests on [GitHub Issues](https://github.com/riga/mermaidmro/issues)

If you like to contribute, I'm happy to receive pull requests.
Just make sure to add a new test cases and run linting and coverage checks:

```bash
> ./tests/test.sh
> ./tests/lint.sh
> ./tests/coverage.sh
```

<!-- marker-after-content -->

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "mermaidmro",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "mro,graph,inheritance,mermaid,dag",
    "author": "",
    "author_email": "Marcel Rieger <github.riga@icloud.com>",
    "download_url": "https://files.pythonhosted.org/packages/b1/c6/a1e118d23e5b6957a30e21a09e41405ada155320250e20f2b59b0b10e036/mermaidmro-0.2.1.tar.gz",
    "platform": null,
    "description": "# mermaidmro\n\n<!-- marker-before-badges -->\n\n[![Build status](https://github.com/riga/mermaidmro/actions/workflows/lint_and_test.yml/badge.svg)](https://github.com/riga/mermaidmro/actions/workflows/lint_and_test.yml)\n[![Package version](https://img.shields.io/pypi/v/mermaidmro.svg?style=flat)](https://pypi.python.org/pypi/mermaidmro)\n[![Python version](https://img.shields.io/badge/Python-%E2%89%A53.7-blue)](https://pypi.python.org/pypi/mermaidmro)\n[![Documentation status](https://readthedocs.org/projects/mermaidmro/badge/?version=latest)](http://mermaidmro.readthedocs.io)\n[![Code coverge](https://codecov.io/gh/riga/mermaidmro/graph/badge.svg?token=UAKGC13BVI)](https://codecov.io/gh/riga/mermaidmro)\n[![License](https://img.shields.io/github/license/riga/mermaidmro.svg)](https://github.com/riga/mermaidmro/blob/master/LICENSE)\n\n<!-- marker-after-badges -->\n\nCreate mermaid graphs from the method resolution order (mro) of Python objects.\n\n\n<!-- marker-before-content -->\n\n## CLI Examples\n\nFor the examples below, let's consider the following classes saved in a file `code.py` that can be imported via `import code` (adjust your `PYTHONPATH` if this is not the case).\n\n```python\n# code.py\n\nclass A(object):\n    pass\n\nclass B(object):\n    pass\n\nclass C(A):\n    pass\n\nclass D(C, B):\n    pass\n```\n\n### Generate mermaid text\n\nSimply pass the module and class in the format `module_name:class_name` to `mermaidmro`.\n\n```shell\n> mermaidmro code:D\n\ngraph TD\n    code.D(\"code.D (0)\")\n    code.C(\"code.C (1)\")\n    code.A(\"code.A (2)\")\n    code.B(\"code.B (3)\")\n    object(\"object (4)\")\n\n    code.C --> code.D\n    code.B --> code.D\n    code.A --> code.C\n    object --> code.B\n    object --> code.A\n```\n\nYou can hide the mro indices by adding `--no-mro / -n`.\n\n```shell\n> mermaidmro code:D --no-mro\n\ngraph TD\n    code.C --> code.D\n    code.B --> code.D\n    code.A --> code.C\n    object --> code.B\n    object --> code.A\n```\n\nYou can also limit the maximum depth via `--max-depth / -m`.\n\n```shell\n> mermaidmro code:D --no-mro --max-depth 1\n\ngraph TD\n    code.A --> code.D\n    code.B --> code.D\n```\n\n\n### Open the graph in your browser\n\nJust configure the executable of your browser you like to open the graph with via `--cmd / -c` (on Macs this is usually just `open`).\nThis functionality is based on the [mermaid.live](https://mermaid.live) service.\n\n```shell\n> mermaidmro code:D --cmd open\n\n# opens https://mermaid.ink/img/pako:eNptkM8KwjAMh18l5JSBE_-dPAht9wgec6lbdYrdZNTT2LvbUUvLWE6_fB8kISPWfWPwDPgY9KeFa8Ud-JrptiLGEIB2BWORORWdAtovnIhOAB0WTkYngY7J9beXqZ13IQCdgss3Qlle_oflA9exSFjlKxKW61jgBtCawepnM_9lZHStsYZ9w9iYu_6-HeOE0w_Nr1i5?type=png\n```\n\nTo open the graph in the live editor, add `--edit`.\n\n\n### Visualize the graph in your terminal\n\nThis requires that you have a tool installed that lets you visualize images in your terminal, e.g. [`imgcat`](https://iterm2.com/documentation-images.html) for [iTerm2](https://iterm2.com).\n\n```shell\n> mermaidmro code:D --visualize imgcat\n\n# shows\n```\n\n![code:D graph](https://media.githubusercontent.com/media/riga/mermaidmro/master/assets/graph.png)\n\n\n### Download the graph\n\n```shell\n> mermaidmro code:D --download graph.png\n```\n\n\n## Installation\n\nSimply install via [pip](https://pypi.python.org/pypi/mermaidmro)\n\n```bash\npip install mermaidmro\n```\n\n\n## Development\n\n- Source hosted at [GitHub](https://github.com/riga/mermaidmro)\n- Report issues, questions, feature requests on [GitHub Issues](https://github.com/riga/mermaidmro/issues)\n\nIf you like to contribute, I'm happy to receive pull requests.\nJust make sure to add a new test cases and run linting and coverage checks:\n\n```bash\n> ./tests/test.sh\n> ./tests/lint.sh\n> ./tests/coverage.sh\n```\n\n<!-- marker-after-content -->\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2023, Marcel Rieger All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "Create mermaid graphs from the method resolution order (mro) of Python objects.",
    "version": "0.2.1",
    "project_urls": {
        "Documentation": "https://mermaidmro.readthedocs.io",
        "Homepage": "https://github.com/riga/mermaidmro",
        "Repository": "https://github.com/riga/mermaidmro.git"
    },
    "split_keywords": [
        "mro",
        "graph",
        "inheritance",
        "mermaid",
        "dag"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "38c16d72c65ab56e020f20ec6ad8152b6db0ae1650b829f5d9da6ba639b299ea",
                "md5": "f7f5a20ddab6420c693424dd12535597",
                "sha256": "9c71fd110f4bc7333ee24fc718102928aa92ae0f62cfde6cd6f3c86de1bdf877"
            },
            "downloads": -1,
            "filename": "mermaidmro-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7f5a20ddab6420c693424dd12535597",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10752,
            "upload_time": "2023-11-23T12:23:35",
            "upload_time_iso_8601": "2023-11-23T12:23:35.834844Z",
            "url": "https://files.pythonhosted.org/packages/38/c1/6d72c65ab56e020f20ec6ad8152b6db0ae1650b829f5d9da6ba639b299ea/mermaidmro-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1c6a1e118d23e5b6957a30e21a09e41405ada155320250e20f2b59b0b10e036",
                "md5": "117f3524c1c6b0c4c41a2ffc483d7d35",
                "sha256": "e471b0103aaf36182a86ba2a2d5ec68c8b28488a981624d863a2bb0a8abac41b"
            },
            "downloads": -1,
            "filename": "mermaidmro-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "117f3524c1c6b0c4c41a2ffc483d7d35",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 15374,
            "upload_time": "2023-11-23T12:23:37",
            "upload_time_iso_8601": "2023-11-23T12:23:37.611462Z",
            "url": "https://files.pythonhosted.org/packages/b1/c6/a1e118d23e5b6957a30e21a09e41405ada155320250e20f2b59b0b10e036/mermaidmro-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-23 12:23:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "riga",
    "github_project": "mermaidmro",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "mermaidmro"
}
        
Elapsed time: 0.20206s