sublime-jsdocs icon indicating copy to clipboard operation
sublime-jsdocs copied to clipboard

Docblock defaults never load when installed from Package Control (zip): no param names, no descriptions

Open dpc00 opened this issue 4 weeks ago • 0 comments

Summary

DocBlockr installed from Package Control (i.e. as a .sublime-package zip) generates docblocks with no description text and no parameter names on Sublime Text 4215. Unpacking the very same package into Packages/DocBlockr/ fixes it completely.

What I did

Sublime Text 4215 (portable, Windows 11 10.0.26300, plugin host Python 3.14.6). Installed DocBlockr 2.14.1 through Package Control, opened a real .js file containing

/**
function foo(a, b) {
}

and ran jsdocs with the caret at the end of the /** line.

What happened

/**
 * 
 * @param  {[type]}
 * @param  {[type]}
 * @return {[type]}
 */
function foo(a, b) {
}

No [foo description], no a / b, no [description] fields. The parameters are counted correctly — only their names and the descriptions are missing.

The same package, unpacked, is correct

I extracted DocBlockr.sublime-package into Packages/DocBlockr/ and restarted Sublime Text. Identical file, identical command:

/**
 * [foo description]
 * @param  {[type]} a [description]
 * @param  {[type]} b [description]
 * @return {[type]}   [description]
 */
function foo(a, b) {
}

Exactly the output in the README.

Why

jsdocs.py:56 takes its settings straight from the view:

viewSettings = view.settings()

and every flag is read from it (self.viewSettings.get('jsdocs_param_name') at jsdocs.py:444, jsdocs_function_description around :420). The defaults live in Base File.sublime-settings, which Sublime Text merges into every view — but only when the package is an unpacked directory. Inside the .sublime-package zip that file is not merged, so every jsdocs_* read returns None, and formatFunction emits an empty description plus a name-less @param for each argument. There is no code-level fallback for a missing key, and the plugin never calls sublime.load_settings.

Evidence from a one-line probe command that dumps view.settings().get(k) for five keys:

installed as jsdocs_param_name jsdocs_align_tags jsdocs_return_tag
DocBlockr.sublime-package absent absent absent
Packages/DocBlockr/ true "deep" "@return"

Suggested fix

Merge the shipped defaults explicitly instead of relying on the view layer, e.g. in plugin_loaded():

base = sublime.load_settings("Base File.sublime-settings")
sublime_plugin.all_callbacks  # or keep a module-level dict and use it as a fallback

simplest is to keep the parsed defaults in a module-level dict and use self.viewSettings.get(key, defaults[key]), so a missing view setting no longer means "off". Alternatively ship the defaults as DocBlockr.sublime-settings and merge it in code, and/or state in the README that the package must be unpacked.

Not tried

Other Sublime Text builds; PHP, CoffeeScript and TypeScript parsers.

dpc00 avatar Nov 08 '26 05:11 dpc00