mirror of https://github.com/amol-/dukpy.git
More documentation
This commit is contained in:
parent
9be4edbf6d
commit
69f0b4c0ee
12
README.rst
12
README.rst
|
@ -19,6 +19,7 @@ It comes with a bunch of common transpilers built-in for convenience:
|
|||
- *BabelJS*
|
||||
- *TypeScript*
|
||||
- *JSX*
|
||||
- *LESS*
|
||||
|
||||
Dukpy has been tested on **Python 2.7** and **Python 3.4**, dukpy
|
||||
is currently not production ready and might actually crash your
|
||||
|
@ -138,6 +139,17 @@ DukPy provides a built-in compiler from JSX to React, this is available as
|
|||
>>> dukpy.jsx_compile('var react_hello = <h1>Hello, world!</h1>;')
|
||||
u'"use strict";\n\nvar react_hello = React.createElement(\n "h1",\n null,\n "Hello, world!"\n);'
|
||||
|
||||
Less Transpiling
|
||||
----------------
|
||||
|
||||
DukPy provides a built-in distribution of the less compiler available
|
||||
through `dukpy.less_compile`:
|
||||
|
||||
.. code:: python
|
||||
|
||||
>>> import dukpy
|
||||
>>> dukpy.less_compile('.class { width: (1 + 1) }')
|
||||
'.class {\n width: 2;\n}\n'
|
||||
|
||||
Using the JavaScript Interpreter
|
||||
--------------------------------
|
||||
|
|
|
@ -4,6 +4,7 @@ from .evaljs import JSInterpreter
|
|||
|
||||
|
||||
class NodeLikeInterpreter(JSInterpreter):
|
||||
"""A DukPy Interpreter that provides a minimal compatibility layer with NodeJS"""
|
||||
def __init__(self):
|
||||
super(NodeLikeInterpreter, self).__init__()
|
||||
self.loader.register_path(os.path.join(os.path.dirname(__file__), 'jscore'))
|
||||
|
@ -12,6 +13,7 @@ class NodeLikeInterpreter(JSInterpreter):
|
|||
|
||||
|
||||
class FS:
|
||||
"""Provides oversimplified fs.js native functions."""
|
||||
@classmethod
|
||||
def exists(cls, filepath):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue