ssb22 / jianpu-ly

Jianpu in Lilypond
http://ssb22.user.srcf.net/mwrhome/jianpu-ly.html
Apache License 2.0
70 stars 18 forks source link

Make jianpu-ly importable #15

Closed SilverRainZ closed 2 years ago

SilverRainZ commented 2 years ago

Hi, I am the author of sphinxnotes-lilypond, an extension for embedding LilyPond score into Sphinx documentation. I want to add Jian Pu support (https://github.com/sphinx-notes/lilypond/issues/17) for it.

It seems that this project is a CLI tool for now. It would be better to make this project importable, so other project (like sphinxnotes-lilypond) can use it.

Thank you~

SilverRainZ commented 2 years ago

I am working on this and will file a PR soon. hope it can be merged eventually.

谢谢~

ssb22 commented 2 years ago

哎哟 how much have you done so far? I started moving some things around already .. basically we first need to make sure it can be imported and doesn't try to do things with sys.argv when __name__ is not "__main__"

SilverRainZ commented 2 years ago

I just make it work in an ugly way, it is quite complex so I indented all functions one level except help and IO.

You are the one most familiar with this program, if you already started, I am so glad to see that, you can do it better than me. I just 乐享其成 :D

ssb22 commented 2 years ago

Just indenting all functions might not work so well: some things needed to be declared global so they could be read by other functions later on. Try now (see test.py). But I'm not sure if it's ready for PyPI .. I expect they have stricter style requirements (haven't checked)

SilverRainZ commented 2 years ago

It works well. Thank you very much~

PyPI is not necessary, I can include this as a git submodule.

SilverRainZ commented 2 years ago

Hi @ssb22, the module name contains a dash so we can't use the import statement directly, any idea to improve this?

https://stackoverflow.com/questions/8350853/how-to-import-module-when-module-name-has-a-dash-or-hyphen-in-it

ssb22 commented 2 years ago

Please just use jianpuly = __import__("jianpu-ly") for now. I know having a hyphen in it is not ideal, but I'm not sure I can change that now without breaking everybody's scripts, except perhaps by adding a second file as a wapper, but then it will no longer be all in one file for those who just wget it.

SilverRainZ commented 2 years ago

Ok, it is ok, I renamed it by using s symlink: https://github.com/sphinx-notes/lilypond/tree/jianpu/sphinxnotes/lilypond

ssb22 commented 2 years ago

好主意☺

SilverRainZ commented 2 years ago

Since there is no other problem, I close this issue.

Thank you very much :D

SilverRainZ commented 2 years ago

Finally, we can write Jian Pu in Sphinx: https://sphinx.silverrainz.me/lilypond/#jianpu-numbered-musical-notation :D