diff --git a/README.md b/README.md index 2ab728cb6f60bebb8fac167d9c811e9c9bb66d82..2c5e082289dda81654cc6b2feecfed8ac4be14b7 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,16 @@ You can simply install it with `pip` command line from the official PyPI site. pip install treevalue ``` -For more information about installation, you can refer to [Installation](https://opendilab.github.io/treevalue/main/tutorials/installation/index.html#). +If you want to link with the [potc](https://github.com/potc-dev/potc) package so that treevalue can support source code conversion, you can use the following command to install it. + +```shell +pip install treevalue[potc] +``` + +For more information about installation, you can refer to + +* [Installation](https://opendilab.github.io/treevalue/main/tutorials/installation/index.html) +* [Potc Plugin Installation](https://opendilab.github.io/treevalue/main/tutorials/plugins/index.html#potc-support) ## Documentation diff --git a/docs/source/index.rst b/docs/source/index.rst index d84cd86b3e2a9d8839aeb4d0e1bfb43ebe68df5c..adc64d93a8bc16c9d4162a9f961fd0cafc99eb6d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -19,6 +19,7 @@ structure processing when the calculation is tree-based. tutorials/basic_usage/index tutorials/advanced_usage/index tutorials/cli_usage/index + tutorials/plugins/index .. toctree:: diff --git a/docs/source/tutorials/plugins/index.rst b/docs/source/tutorials/plugins/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..9d417053ed2f82b1e9326676fb1d5f2432cd23f7 --- /dev/null +++ b/docs/source/tutorials/plugins/index.rst @@ -0,0 +1,37 @@ +Plugins +=============== + +Potc support +--------------------- + +`Potc `_ is a package that can convert any object into executable source code. +For ``treevalue``, potc can support the source code transformation of treevalue objects through +the installation of additional plugins. So we can execute the following installation command + +.. code:: shell + + pip install treevalue[potc] + +After this installation, you will be able to directly convert treevalue to an object without any additional operations. +Such as + +.. literalinclude:: ./potc_demo.demo.py + :language: python + :linenos: + +The output should be + +.. literalinclude:: ./potc_demo.demo.py.txt + :language: text + :linenos: + +Also, you can use the following CLI command to get the same output results as above. + +.. code:: shell + + potc export -v 'test_simple.t' -v 'test_simple.st' -v 'test_simple.r' + +For further information, you can refer to + +* `potc-dev/potc `_ +* `potc-dev/potc-treevalue `_ diff --git a/docs/source/tutorials/plugins/potc_demo.demo.py b/docs/source/tutorials/plugins/potc_demo.demo.py new file mode 100644 index 0000000000000000000000000000000000000000..fb155deb27bbc59ba9e2a77da911f75419147c8b --- /dev/null +++ b/docs/source/tutorials/plugins/potc_demo.demo.py @@ -0,0 +1,19 @@ +from potc import transvars + +from treevalue import FastTreeValue, raw + +r = raw({'a': 1, 'b': 2, 'c': [3, 4]}) +t = FastTreeValue({ + 'a': 1, 'b': 'this is a string', + 'c': [], 'd': { + 'x': raw({'a': 1, 'b': (None, Ellipsis)}), + 'y': {3, 4, 5} + } +}) +st = t._detach() +if __name__ == '__main__': + _code = transvars( + {'t': t, 'st': t._detach(), 'r': r}, + reformat='pep8' + ) + print(_code) diff --git a/requirements-doc.txt b/requirements-doc.txt index 0b603d05a3ae75ca8e5dfb12f242b8b10ce2fb98..9325b15e9d4831804d5e1bc183c3c2019e3f1348 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -8,4 +8,5 @@ sphinx-multiversion~=0.2.4 where~=1.0.2 numpy>=1.19,<2 easydict>=1.7,<2 -scikit-learn>=0.24.2 \ No newline at end of file +scikit-learn>=0.24.2 +potc-treevalue>=0.0.1 \ No newline at end of file diff --git a/requirements-potc.txt b/requirements-potc.txt new file mode 100644 index 0000000000000000000000000000000000000000..acf46dddd98181cc8bce6f3526eaf2407972b7e3 --- /dev/null +++ b/requirements-potc.txt @@ -0,0 +1 @@ +potc-treevalue>=0.0.1 \ No newline at end of file