rocher


Namerocher JSON
Version 0.47.0 PyPI version JSON
download
home_pageNone
SummaryRocher is wrapper arround the Monaco code Editor. It can be embed into any Python web application. Helper for Flask is provided.
upload_time2024-03-24 11:23:17
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords monaco code diff editor
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Rocher

<a href="https://pypi.python.org/pypi/rocher"><img src="http://img.shields.io/pypi/dm/rocher.svg"></a>

Rocher is a Python package for the Monaco code editor. The Monaco Editor is the code editor that powers Visual Studio Code. It provides a prebuilt version of the editor as a Python package, allowing you to embed it into any Python application as a standard Python package.

![Screenshot](screenshot.png)

## Installation

```bash
pip install rocher
```

## Usage

See the [samples/](Samples) folder for more examples to use it with multiple frameworks.

### Path

The package provides only a function path():
    
```python   
import rocher

rocher.path()
```

This is the path where the Monaco editor is installed. You can serve after this path with your favorite Python web framework as a static folder.

### Editor HTML

The package provides a editor_html():

```python
import rocher

rocher.editor_html(
    "/static/vs",
    "container",
    "python",
    "print('Hello World!')",
)
```

This function will return a HTML string that you can embed in your web page. The first parameter is the path where the Monaco editor is exposed. The second parameter is the id of the HTML element where the editor will be embedded. The third parameter is the language of the editor. The fourth parameter is the initial content of the editor.

### Colorizer

The package also a simple syntax highlighter:

```python
import rocher

rocher.colorize_html("container")
```

This function will return a HTML string that you can embed in your web page. The first parameter is the id of the HTML element where the content will be highlighted.


### Flask

The package provide an helper for Flask + Jinja2:

```python

First you need to register the editor

```python
from flask import Flask
import rocher.flask

app = Flask(__name__)

rocher.editor_register(app)
```
    
Then you can use the editor in your template:
    
```django
<div id="container" style="width:800px;height:600px;border:1px solid grey"></div>
{{
    rocher_editor(
        "container",
        "python",
        source_code,
        readOnly=true,
        theme="vs-dark",
        lineHeight=20
    )
}}
```

All supported options are listed here: https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html


Or the colorizer:

```django
{{ rocher_colorize("code", initialize=False) }}

<h2>Python</h2>
<pre id="code" data-lang="python" style="width: 500px">
print("Hello World!")
</pre>
```

## Why the name Rocher?

Le Rocher is the hill where the Principality of Monaco is built. 

## Versioning

Following semantic versioning convention the major and version number of this package is the version of the Monaco Editor. The patch number is use to release a version of this package independent of the Monaco Editor version.

## Update the Monaco Editor

Edit update_editor.sh and change the version number. Then run the script. It will download the new version of the Monaco editor and update the package.

And run:    
```bash
hatch build -t sdist 
```
To build the packaged version.

## I can't find the Monaco Editor source code in the repository

The Monaco Editor is not part of this repository. It is downloaded from the official repository during the build process. See the update_editor.sh script.


## License

Licensed under the MIT License, see [LICENSE](LICENSE) for more information.

## Credits

All credit goes to the Monaco Editor team. This package is just a wrapper around their work.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rocher",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Monaco, code, diff, editor",
    "author": null,
    "author_email": "Julien Duponchelle <julien@duponchelle.info>",
    "download_url": "https://files.pythonhosted.org/packages/cf/19/9d2ebfeff0676874eeb4d065683d72d43f126575b1d00091f47c66e9578e/rocher-0.47.0.tar.gz",
    "platform": null,
    "description": "# Rocher\n\n<a href=\"https://pypi.python.org/pypi/rocher\"><img src=\"http://img.shields.io/pypi/dm/rocher.svg\"></a>\n\nRocher is a Python package for the Monaco code editor. The Monaco Editor is the code editor that powers Visual Studio Code. It provides a prebuilt version of the editor as a Python package, allowing you to embed it into any Python application as a standard Python package.\n\n![Screenshot](screenshot.png)\n\n## Installation\n\n```bash\npip install rocher\n```\n\n## Usage\n\nSee the [samples/](Samples) folder for more examples to use it with multiple frameworks.\n\n### Path\n\nThe package provides only a function path():\n    \n```python   \nimport rocher\n\nrocher.path()\n```\n\nThis is the path where the Monaco editor is installed. You can serve after this path with your favorite Python web framework as a static folder.\n\n### Editor HTML\n\nThe package provides a editor_html():\n\n```python\nimport rocher\n\nrocher.editor_html(\n    \"/static/vs\",\n    \"container\",\n    \"python\",\n    \"print('Hello World!')\",\n)\n```\n\nThis function will return a HTML string that you can embed in your web page. The first parameter is the path where the Monaco editor is exposed. The second parameter is the id of the HTML element where the editor will be embedded. The third parameter is the language of the editor. The fourth parameter is the initial content of the editor.\n\n### Colorizer\n\nThe package also a simple syntax highlighter:\n\n```python\nimport rocher\n\nrocher.colorize_html(\"container\")\n```\n\nThis function will return a HTML string that you can embed in your web page. The first parameter is the id of the HTML element where the content will be highlighted.\n\n\n### Flask\n\nThe package provide an helper for Flask + Jinja2:\n\n```python\n\nFirst you need to register the editor\n\n```python\nfrom flask import Flask\nimport rocher.flask\n\napp = Flask(__name__)\n\nrocher.editor_register(app)\n```\n    \nThen you can use the editor in your template:\n    \n```django\n<div id=\"container\" style=\"width:800px;height:600px;border:1px solid grey\"></div>\n{{\n    rocher_editor(\n        \"container\",\n        \"python\",\n        source_code,\n        readOnly=true,\n        theme=\"vs-dark\",\n        lineHeight=20\n    )\n}}\n```\n\nAll supported options are listed here: https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html\n\n\nOr the colorizer:\n\n```django\n{{ rocher_colorize(\"code\", initialize=False) }}\n\n<h2>Python</h2>\n<pre id=\"code\" data-lang=\"python\" style=\"width: 500px\">\nprint(\"Hello World!\")\n</pre>\n```\n\n## Why the name Rocher?\n\nLe Rocher is the hill where the Principality of Monaco is built. \n\n## Versioning\n\nFollowing semantic versioning convention the major and version number of this package is the version of the Monaco Editor. The patch number is use to release a version of this package independent of the Monaco Editor version.\n\n## Update the Monaco Editor\n\nEdit update_editor.sh and change the version number. Then run the script. It will download the new version of the Monaco editor and update the package.\n\nAnd run:    \n```bash\nhatch build -t sdist \n```\nTo build the packaged version.\n\n## I can't find the Monaco Editor source code in the repository\n\nThe Monaco Editor is not part of this repository. It is downloaded from the official repository during the build process. See the update_editor.sh script.\n\n\n## License\n\nLicensed under the MIT License, see [LICENSE](LICENSE) for more information.\n\n## Credits\n\nAll credit goes to the Monaco Editor team. This package is just a wrapper around their work.",
    "bugtrack_url": null,
    "license": null,
    "summary": "Rocher is wrapper arround the Monaco code Editor. It can be embed into any Python web application. Helper for Flask is provided.",
    "version": "0.47.0",
    "project_urls": {
        "Documentation": "https://github.com/julien-duponchelle/rocher#readme",
        "Issues": "https://github.com/julien-duponchelle/rocher/issues",
        "Source": "https://github.com/julien-duponchelle/rocher"
    },
    "split_keywords": [
        "monaco",
        " code",
        " diff",
        " editor"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "02067172a3539c7057a49be6cd155eb74a79da1e486645288bd50c69d822e897",
                "md5": "7a5a0a9e46344e91141b85d307700059",
                "sha256": "9826ddc855a4bfcef164d88887816917ad5715f648a6bf6975c92a7287e6ee71"
            },
            "downloads": -1,
            "filename": "rocher-0.47.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a5a0a9e46344e91141b85d307700059",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3043955,
            "upload_time": "2024-03-24T11:23:15",
            "upload_time_iso_8601": "2024-03-24T11:23:15.807853Z",
            "url": "https://files.pythonhosted.org/packages/02/06/7172a3539c7057a49be6cd155eb74a79da1e486645288bd50c69d822e897/rocher-0.47.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cf199d2ebfeff0676874eeb4d065683d72d43f126575b1d00091f47c66e9578e",
                "md5": "98c4d1c9281ac7f326966f7c3796a78a",
                "sha256": "a97da36b713942e5e7c0ef50327a93aa08c3e97f7681fe5cb0a088d8ca7492a0"
            },
            "downloads": -1,
            "filename": "rocher-0.47.0.tar.gz",
            "has_sig": false,
            "md5_digest": "98c4d1c9281ac7f326966f7c3796a78a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 2927949,
            "upload_time": "2024-03-24T11:23:17",
            "upload_time_iso_8601": "2024-03-24T11:23:17.910808Z",
            "url": "https://files.pythonhosted.org/packages/cf/19/9d2ebfeff0676874eeb4d065683d72d43f126575b1d00091f47c66e9578e/rocher-0.47.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-24 11:23:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "julien-duponchelle",
    "github_project": "rocher#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rocher"
}
        
Elapsed time: 0.19910s