Last modified: 2014-04-23 13:05:17 UTC
Script viewer software should support sections and section editing, using one-line comments (or special formatting therein) for heading syntax. --------------------------------------------- /* Foo */ Foo.prototype.bar = function(){ ... }; Foo.prototype.baz = function(){ ... }; ^^^^^ everything above is in the Foo section /* Foo 2 */ <---------- this becomes a heading Foo2.prototype.bar = function(){ ... }; Foo2.prototype.baz = function(){ ... }; ^^^^^ everything above is in the foo 2 section ---------------------------------------------
Hi, what is "Script viewer"? Is this [[mw:Extension:CodeEditor]]?
Whatever I see when reading or editing [[Special:MyPage/common.js]]. (There is one extension which highlights the code when reading it, and another extension which is responsible for the code editor; I don't know which one this bug falls under, since both of them would have to support editing a section of a JS or CSS script.)
(Or Lua script.)
See also https://bugzilla.wikimedia.org/show_bug.cgi?id=43008#c2
https://test.wikipedia.org/wiki/User:Gryllida/common.js a stupid ugly workaround https://test.wikipedia.org/wiki/User:Gryllida/afch2/v2 with sections syntax highlight ok, code-editor does not pick it up
Can I ask why ? I mean a section in Javascript is usually not a self-contained unit, it only has meaning icw all the other stuff. So I'm trying to understand why you would want to edit it in that way. Can you clarify how this helps you to edit code ?
There are two reasons behind this. 1) Usually people contain different objects in different files. On wiki, browsing (or simply creating) different files and subfiles of a JS file is far from intuitive. It could make sense to add support for sections. 2) Inline (POD-like) documentation would benefit readability. See i.e. http://juerd.nl/site.plp/perlpodtut . In other words, CodeEditor should be capable of editing any <source> block on a page without entering edit mode for the entire page. I am renaming the bug title accordingly.
We actually have a geshi module that does this in the CodeEditor codebase, but it's only the editor mockup, it's not actually able to make changes to the wikitext right now. Because you seem to be interested in similar functionality, I have fixed up the module in this patch: https://gerrit.wikimedia.org/r/#/c/127451/ Making it fully work would be quite some additional work still, but it's not as far away as I initially figured. The biggest problem is that we need to make sure not to implement everything a dozen times (live preview, editpage, visual editor and inline code editor).