Skip to content

Practice of "method stub" generation feature implementation.

License

Notifications You must be signed in to change notification settings

linahbei/code-generator-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Lightning Talk -- 《人生第一個 Python “Code Generator”》

tags: Lightning Talk

License: Public Domain / No Copyright


簡報資料

說明

下載範例專案

$ git clone https://github.com/linahbei/code-generator-practice
$ cd code-generator-practice/python

User 範例程式

$ python3 src/foo_example.py      
Say: bar
Say: bar

Foo package 的 code generator 指令

Usage

$ python3 src/foo.py -h
usage: foo.py [-h] [--out filename.py]

optional arguments:
  -h, --help           show this help message and exit
  --out filename(.py)  Export example code.

Example

從螢幕顯示結果,並產生程式碼檔案

$ python3 src/foo.py --out example
class FooUsageExample:
    @staticmethod
    @Foo.sayAgainWrapper
    def say_again(say: str):
        print(say)

查看產生的程式碼檔案

$ cat example.py 
class FooUsageExample:
    @staticmethod
    @Foo.sayAgainWrapper
    def say_again(say: str):
        print(say)

跑一下測試

$ python3 -m unittest tests/test_foo_package.py

About

Practice of "method stub" generation feature implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages