[英]The difference between st2 and st3 about on_query_completions
[英]Create sublime text plugin support both ST2 and ST3
我為Sublime Text 2制作了幾個插件,但是當Sublime Text 3出來時,它有一個新的Python引擎,我的插件停止工作。 我設法通過逐個調試所有問題來修復它們,但現在我有兩個版本。 原始版本從Package Manager順利安裝,但新版本只能從我從git檢出的代碼分支中安裝。
我應該如何正確管理sublime文本的插件以支持多個版本?
有沒有關於如何有效地做到這一點的博客文章?
您可以為Sublime Text的不同構建管理兩個不同的代碼分支。 如果你看看第200行及其后的example-repository.json
,你會看到這個例子:
// If your package is only compatible with specific builds of
// Sublime Text, this will cause the package to be hidden from
// users with incompatible versions.
{
"details": "https://github.com/wbond/sublime_alignment",
"releases": [
{
// This branch (default: "master") is for Sublime Text 2.
// Remember: The sublime_text key is required!
"sublime_text": "<3000",
"details": "https://github.com/wbond/sublime_alignment"
}
{
// This branch ("st3") is for Sublime Text 3 (and above).
// You can specify as many releases as you want.
"sublime_text": ">=3000",
"details": "https://github.com/wbond/sublime_alignment/tree/st3"
}
]
},
這樣,如果您為不同版本的ST或甚至ST3的不同版本提供不同的代碼庫,如果您依賴於僅在某個版本中實現的某些API更改,最終用戶將無縫地獲取您的版本你想要他們的插件。
這可能是不可能的,這取決於您如何使用API,但從長遠來看,最簡單的方法是在ST2和ST3之間協調您的代碼。 如果需要使用某些高級功能,則可以始終使用此類構造:
if sublime.version() >= 3000:
do_advanced_stuff()
else:
do_st2_stuff()
分解代碼並優雅地失敗,在某些情況下,在ST2下運行的某些插件可能不具備使用ST3時所具有的功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.