Espresso Sugar Standard
Posted: 19 January 2009 04:01 AM   [ Ignore ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05

Well, quite a few of us have been working non-stop on GitHub and in IRC to put together a set of specifications for Sugar development and theming. After quite a lot of discussion and argument, we’ve come to a conclusion that we altogether find acceptable.

Several caveats (as laid out more verbosely in the readme): This was primarily written by myself to govern my own Sugar development, and to govern the contributions of others to Sugars managed by myself. However, Alex and the few others who have seen it so far really liked it, as such, I’ve decided to clean it up, and work in some suggestions from others, and publish it for general use.

I’m posting this here for comments and ideas from the entire Sugar development community; however, don’t be insulted if I don’t accept your suggestion.

Also: You probably shouldn’t bother implementing this naming convention set in your Sugars just yet (if you’re going to do so, that is) - there’s a good chance a lot of it will change after going through this release candidate phase on the forums. I hope to stabilize/finalize it in the next week or so, and finally lock it down as “version one” of the spec before the end of next week (around the end of January, in other words).

The GitHub repository for these specifications is here (though I suggest you simply watch this forum thread, as it will be updated with any finalized release version when such has been completed): http://github.com/elliottcable/espresso-sugar-standard/

Update: This standard has now been deemed final. Please adhere to it in your Sugars and Themes; it’s appreciated by your counterparts!

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 19 January 2009 04:01 AM   [ Ignore ]   [ # 1 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05

Programming language zone naming policies (PLZN)

Important: You’ll want to read the introduction if you’re planning to write a Sugar or a theme based on this spec. There’s some rules and caveats to understand before you start using it.

Literals
A literal is an element that is directly typed into the source code. In
some languages, these might be called constants - however, I consider that too
ambiguous, as most languages which Espresso users will often come across, a
constant means something else entirely (see `keyword.constant`).

* literal…
  * literal.string…: `“hello world”`
  * literal.string.heredoc…
  * literal.regex…: `/^([\w]+).*$/`
  * literal.numeric
  * literal.numeric.integer
    * literal.numeric.integer.binary…: `0b1, 0b101010`, and in some languages `-0b1000`
    * literal.numeric.integer.decimal…: `1, 42`, and in some languages `-8`
    * literal.numeric.integer.octal…: `01, 052`, and in some languages `-010`
    * literal.numeric.integer.hex…: `0x1, 0x2A`, and in some languages `-0x8`
  * literal.numeric.float…: `1.0, 4.2`, and in some languages `-8.8`
  * literal.numeric.exponent…: `e1, e42` (should identify the exponential part of the literal, not the entire literal)
  * literal.collection
  * literal.collection.set…: (I don’t actually know of any language that has a literal construct for a set, but if one does, it would go here)
  * literal.collection.array…: `[1, 2, 3]`
  * literal.collection.dictionary…: `Hash` in Ruby, `dict` in Python, `array()` in PHP
  * literal.keyword: (any value that acts as a keyword but returns a single, known value)
  * literal.keyword.bool…: `true, false`
  * literal.keyword.nothing…: `nil, NULL, undefined, NaN`
  * literal.escape…: `\e, \{, \!`
  * literal.escape.linebreak `\n, \r\n, \x0D\x0A, PHP_EOL`
  * literal.escape.tab `\t`

Identifiers
An identifier is a syntatical element that uniquely identifies one object of
some sort in the language. This isn’t restricted to the Object-Oriented
Language definition of ‘object’, this also means anything in a language which
can be referenced in some way.

* identifier
  * identifier.function: `func(1, 2, 3)` _(referring to a identifier that points to a specific function - such as a function/method call)_
  * identifier.type: `NSString`, `HTTP`, `Fixnum`, `double` _(an umbrella for ‘prototypes’, ‘classes’, ‘types’, and any other language feature that serves a similar purpose)_
  * identifier.variable…
  * identifier.variable.constant…: `Var`, `VAR`
  * identifier.variable.global…: `$var` in Ruby, `$_VAR` in PHP
  * identifier.variable.instance…: `@var`, `@@var`
  * identifier.variable.local…: `var`
  * identifier.variable.parameter…: `var` in the context of a method definition

Keywords
A keyword is an element defined in the language’s definition itself - it can’t
be changed by the programmer, and it usually invokes or references something
hardcoded into the language’s compiler/parser/interpreter.

* keyword
  * keyword.control: (used for loops, conditionals and general flow control)
  * keyword.control.exception…: `raise, rescue, ensure, throw, catch` (used to manage exceptions)
  * keyword.control.flow…: `while, for, break, goto, if`/`then`/`else, begin…end` (changes the ‘direction’ of / current location in the executing code)
  * keyword.modifier…: (used for tacking onto declarations)
  * keyword.modifier.scope…: `public, protected, private` (changes the ‘scope’ of a particular declaration)
  * keyword.definition…: `class, function, method, module, lambda` (used for creating or modifying a container)

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 19 January 2009 04:02 AM   [ Ignore ]   [ # 2 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05

Containers
These are less being defined for the purpose of highlighting, and more for use
in attaching Itemizers, and for the purpose of the subzones. Any syntactical
construct that is meant to seperate out a piece of code from other code, goes
here.

* container:
  * container.class…
  * container.function…
  * container.block…: `lambda {}` in Ruby, anonymous function in JavaScript, closures in many other languages (any block of code that acts as exactly that, a block of code)
  * container.expression…
  * container.statement…

Metadata
This is mostly for comments - I can’t think of anything else to go under this
heading, but there may be such things.

* metadata…: (for information that will be ignored by the compiler/interpreter, or has semantic meaning beyond that involved in it’s normal execution)
  * metadata.type-signature: `map :: (a -> b) -> [a] -> [ b]` from Haskell
  * metadata.comment
  * metadata.comment.line…
  * metadata.comment.block…
  * metadata.comment.documentation…: RDoc/YARD, JavaDoc, phpDocumentor comments (comments formulated in a way accepted by the community and documentation-generating-tools to be documentation-blocks)
  * metadata.processing…: `#define, #ifdef` (anything that changes the way code is compiled/interpreted, but isn’t code itself)
  * metadata.processing.comment… `# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-` in emacs or `# encoding: utf-8` in Ruby (other sorts of magic comments that affect the code)
    * metadata.processing.comment.shebang: `#!/usr/bin/env ruby -Ku` (UNIX shell scripting shebangs)

Operators
The difference between operators and keywords bears some discussing. Operators
are almost always punctuation, whereas keywords are almost always textual.
There are exceptions to this rule (`and` and `or` are operators, because
they’re simply alternatives to `&&` and `||`), but it’s a good generalization.

* operator
  * operator.comparator…: `<, >, <=, >=, ==, ===`
  * operator.accessor…: `=, +=, -=, *=, ||=`, as well as `*var` and `&var;` from C (for getters/setters/assignments)
  * operator.mathematical…: `+, -, *, /, %`
  * operator.logical…: `!!, &&, ||, ^, !, &, |`

Delimiters
Delimiters are things that, well, delimit. They mark the edges of things,
where one thing becomes another, or where two things become one.

* delimiter
  * delimiter.balanced…
  * delimiter.balanced.quote
    * delimiter.balanced.quote.double: `“these”`
    * delimiter.balanced.quote.single: `‘these’`
    * delimiter.balanced.quote.backtick: `` `these` ``
  * delimiter.balanced.parenthesis: `(these)`
  * delimiter.balanced.square-brace: `[these]`
  * delimiter.balanced.curly-brace: `{these}`
  * delimiter.seperator…
  * delimiter.seperator.namespace…: `::` in ruby
  * delimiter.seperator.comma: `,`
  * delimiter.seperator.pairing…: `=>` in Ruby, ’:’ in JavaScript
  * delimiter.terminator

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 19 January 2009 04:02 AM   [ Ignore ]   [ # 3 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05

Markup language zone naming policies (MLZN)

Important: This section is extremely incomplete. I really need your input in this area, any ideas are welcome.

Stylistic
This section is for elements of markup that are purely presentational.

* stylistic
  * stylistic.color
  * stylistic.typography: `<font>this is different!</font>`
      * stylistic.typography.weight…: `*bold*, <b>bold</b>, &91;b&93;bold` (for elements that specifically change the weight of an element)
      * stylistic.typography.variant…: `^super^, <sup>super</sup>` (for elements that change which variant of a type family is used - superscript, subscript, italic, display, header, thin, etc)
        * stylistic.typography.variant.slant…: `_italic_, <i>italic</i>` (used to display italics and obliques)
      * stylistic.typography.size…: `<big>huge</big>, <small>tiny</small>` (used to change the point size of a typeface)

Structural
These markup elements lend structure to the page, in a specifically semantic
(not just visual) way.

* structural
  * structural.container…
      * structural.container.section…: `<div>some stuff</div>` (any element referring to a section of a document)
      * structural.container.paragraph: `<p>Hi, I’m some text!</p>` (any element referring specifically to a paragraph of text)
  * structural.header…
      * structural.header.title: `<h1>a title</h1>, a title\n=======` (any title header)
      * structural.header.section: `<h2>a section</h2>, a section\n————-` (any section header)
      * structural.header.tertiary…: `<h3>Unimportent</h3>, <h5>Unimportent</h5>` (for any header that isn’t a title nor a section header)
  * structural.seperator…: `<hr/>,————`

Miscellaneous
Other stuff. This needs a better name. **Unfinished!**

* miscellaneous
  * miscellaneous.connection…: `<a href=‘http://google.com/’>Google</a>` (any connection to something else, internal or external)

Metadata
Anything that affects the content of the document, but isn’t an actual part of
the text of the document.

* metadata
  * metadata.comment…: `<!—a comment—>`
  * metadata.processing…: anything in HTML’s `<head>` block (things which are in the document, and change the processing of the document, but aren’t actual text)
      * metadata.processing.title

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 19 January 2009 04:02 AM   [ Ignore ]   [ # 4 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05

Languages.xml extensions (LXE)

I’ve defined some extensions to the standard Espresso `Languages.xml` that allow a Sugar developer to convey more information abut their Sugar. These extensions primarily allow your Sugar to be indexed by my Sugar Manager.sugar and alexgordon’s Coffee House.

Usage
These elements should be placed in a `<meta>` section of your `Languages.xml` file, as follows:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
  
  <
language id="com.someone.something">
    <!-- 
You should already have this, if you're defining a language -->
  </language>
  
  <meta>
    <!-- Extension'
s elements go here -->
  </
meta>
  
</
settings

Elements

<name> (required)
The `<name>` element should contain, quite simply, the name of the sugar. In the vast majority of cases, this is going to be identical to the name of the folder in which the sugar’s Language.xml file resides, but minus the `.sugar` extension.

<name>Django</name

<description>
This should be a short and succinct description of the sugar. No formatting is guaranteed to be interpreted. This shouldn’t often be longer than a sentance or two.

<description>Fully describes the Django web framework for Python</description

<author> (required)
The author’s (your) name(s). May be multiple names seperated by ”, ”.

<author>elliottcableAlex Gordon</author

<identifier> (required)
Identifier string (for the whole sugar, not the same as the language string above). Should probably look like ‘tld.domain.Sugar.Language-name’ or ‘tld.domain.Sugar.Language-name.framework’. For example, ‘com.mydom.Sugar.Ruby’ or ‘com.mydom.Sugar.Ruby.Rails’.

<identifier>name.elliottcable.Sugar.Python.Django</identifier

<version status=”“> (required)
This should store the current ‘version string’ of the sugar. If you change this number, systems may prompt the user to update your sugar.

The `status` attribute must be one of the following
- `development`: Not working at all, still under active development in preparation for a preview version or a release
- `preview`: Working, but not fully functional. Intended as a ‘feature preview’ for beta testers or interested parties
- `release`: A release version, this is prepared for general use.

<version status="preview">0.1b2</version>
<!-- ...or... -->
<
version status="release">2.1</version

<download format=”“> (required)
This should provide a publicly-accessibe URL at which the sugar’s uncompiled sources can be accessed.

The ‘format’ attribute should be one of the following:
- raw: Only to be used internally by systems. *Do not use*.
- tgz: URL references a tarred GZIP
- zip: URL references a zipfile
- svn: URL references the Sugar directory’s path in a SVN repository
- git: URL references a publicly-accessible git upstream
In all cases, the archive/repository should have the Sugar directory as it’s root - that is, the Languages.xml file and Sugar folders (Syntaxes, Itemizers, etc…) should all be directly within the root of the archive/ repository, not within a subfolder.

This URL should point to the version of the sugar referenced by the `<version>` tag in this same file, that is, don’t simply point at the latest version (if you’re pointing at a downloadable file and not a repository).

<download format="git">git://github.com/elliottcable/django.sugar.git</download>
<!-- ...or... -->
<
download format="zip">http://stuff.elliottcable.name/django.sugar.2.1.zip</download> 

<url>
The ‘home URL’ of the Sugar. This could be a project website, your personal website, or any URL at which the user could get more information about your Sugar’s features and purpose before installing it.

<url>http://github.com/elliottcable/django.sugar/</url> 

<dependencies>
This is an array of dependency elements, each of which references the identifier of a Sugar upon which this Sugar depends. Dependencies will be automatically installed first if found, and this sugar will marked as unavailable if it’s dependencies are not found / unavailable.

This tag may be omitted, or left empty. Both will be assumed to mean that this Sugar will work without any dependencies.

<dependencies>
  <
dependency id="name.elliottcable.Sugar.Python">Python</dependency>
</
dependencies

[removed]
A shell script / shell command to be executed after the sugar is acquired, but before it is installed.

This will be executed with the downloaded and uncompressed directory as the working directory. No other environment is guaranteed, so be as explicit as possible. This is primarily intended for Cocoa sugars to compile themselves before installation.

This tag may also appear more than once, though that should be avoided. Order of execution is not guaranteed.

[removed]/usr/bin/xcodebuild[removed] 

<build-directory>
If it is not sufficient for your sugar to be copied verbatim into the Sugars directory as-is, such as if your sugar is compressed into a sub-directory or your sugar has to be compiled and then copied from a build folder, then you should define a relative path to your *actual* `.sugar` folder here.

<build-directory>build/Release/Sugar Manager.sugar</build-directory

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 19 January 2009 04:03 AM   [ Ignore ]   [ # 5 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05

Ignore this, saving this spot incase I need it for a future extension to the spec - damn you, Expression Engine for putting a maximum of 6,000 characters on posts!

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 19 January 2009 04:04 AM   [ Ignore ]   [ # 6 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05

Ignore this, saving this spot too incase I need it for a future extension to the spec - damn you, Expression Engine for putting a maximum of 6,000 characters on posts!

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 20 February 2009 01:47 AM   [ Ignore ]   [ # 7 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-19
elliottcable - 19 January 2009 04:01 AM

* identifier
  * identifier.function: `func(1, 2, 3)` _(referring to a identifier that points to a specific function - such as a function/method call)_
  * identifier.type: `NSString`, `HTTP`, `Fixnum`, `double` _(an umbrella for ‘prototypes’, ‘classes’, ‘types’, and any other language feature that serves a similar purpose)_
  * identifier.variable…
      * identifier.variable.constant…: `Var`, `VAR`
      * identifier.variable.global…: `$var` in Ruby, `$_VAR` in PHP
      * identifier.variable.instance…: `@var`, `@@var`
      * identifier.variable.local…: `var`

I wasn’t in on all the discussions, but wouldn’t constants go under their own tree? So:
* identifier.constant…
    * identifier.constant.class…: `SomeClass::ClassConstant`
    * identifier.constant.global…: `SOME_CRAZY_CONSTANT_IN_ALL_CAPS`

(examples from PHP)

Profile
 
 
Posted: 20 February 2009 02:44 AM   [ Ignore ]   [ # 8 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05
donut - 20 February 2009 01:47 AM
elliottcable - 19 January 2009 04:01 AM

* identifier
  * identifier.function: `func(1, 2, 3)` _(referring to a identifier that points to a specific function - such as a function/method call)_
  * identifier.type: `NSString`, `HTTP`, `Fixnum`, `double` _(an umbrella for ‘prototypes’, ‘classes’, ‘types’, and any other language feature that serves a similar purpose)_
  * identifier.variable…
      * identifier.variable.constant…: `Var`, `VAR`
      * identifier.variable.global…: `$var` in Ruby, `$_VAR` in PHP
      * identifier.variable.instance…: `@var`, `@@var`
      * identifier.variable.local…: `var`

I wasn’t in on all the discussions, but wouldn’t constants go under their own tree? So:
* identifier.constant…
    * identifier.constant.class…: `SomeClass::ClassConstant`
    * identifier.constant.global…: `SOME_CRAZY_CONSTANT_IN_ALL_CAPS`

(examples from PHP)

I decided to treat them as variables, because they are, well, variables. Also, we’re using (currently … I still have problems with this, but it has unanimous support from everybody who isn’t me) identifier.type to select class names (Such as SomeClass). However, in most languages, these are indistinguishable from normal constants, so I expect most class names to be hilighted as identifier.variable.constant.

I’m open to input, though, if you have a convincing argument as to why constants shouldn’t be treated as variables.

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 08 April 2009 01:43 PM   [ Ignore ]   [ # 9 ]
Newbie
Rank
Total Posts:  8
Joined  2009-04-08

I bought Espresso as part of the MacHeist bundle a few days ago, but currently already use (paid-for versions of) both TextMate and Coda. I can see the benefits of switching from TextMate to Espresso, but one issue is 100% what’s stopping me: I can’t colour code properly. I understand CSS perfectly, but the lack of naming conventions makes it impossible for me to manually edit everything to my exact preference without trawling for hours through the code of Sugars.

Something like the above specification would make the lives of individual (OCD :p) users a lot more bearable.

Profile
 
 
Posted: 08 April 2009 01:56 PM   [ Ignore ]   [ # 10 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05
Studio Aneurin - 08 April 2009 01:43 PM

I bought Espresso as part of the MacHeist bundle a few days ago, but currently already use (paid-for versions of) both TextMate and Coda. I can see the benefits of switching from TextMate to Espresso, but one issue is 100% what’s stopping me: I can’t colour code properly. I understand CSS perfectly, but the lack of naming conventions makes it impossible for me to manually edit everything to my exact preference without trawling for hours through the code of Sugars.

Something like the above specification would make the lives of individual (OCD :p) users a lot more bearable.

It’s already a standard.

The only Sugars and Themes not complying are those that are shipped with Espresso itself; and I’m in the middle of re-writing all of those to use this standard as well.

So, go ahead and write your themes (and Sugars, if you’re so inclined) according to this standard - The revised and revamped built-ins will hopefully ship with Espresso 1.0.2 (assuming I finish them in time).

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 08 April 2009 02:04 PM   [ Ignore ]   [ # 11 ]
Newbie
Rank
Total Posts:  8
Joined  2009-04-08
elliottcable - 08 April 2009 01:56 PM
The only Sugars and Themes not complying are those that are shipped with Espresso itself; and I’m in the middle of re-writing all of those to use this standard as well.

In that case, I’ll be a happy MacRabbit (bunny) as soon as those are ready! :-)

Profile
 
 
Posted: 08 April 2009 02:53 PM   [ Ignore ]   [ # 12 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05
Studio Aneurin - 08 April 2009 02:04 PM
elliottcable - 08 April 2009 01:56 PM
The only Sugars and Themes not complying are those that are shipped with Espresso itself; and I’m in the middle of re-writing all of those to use this standard as well.

In that case, I’ll be a happy MacRabbit (bunny) as soon as those are ready! :-)

You should get in the IRC channel, see the stickied thread in this forum.

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 13 April 2009 09:36 PM   [ Ignore ]   [ # 13 ]
Jr. Member
RankRank
Total Posts:  43
Joined  2008-10-29

How shall I name starting ruby tags?

<% code %> 

 Signature 

Markdown.sugar – The super-awesome Markdown for Espresso.

Profile
 
 
Posted: 13 April 2009 09:41 PM   [ Ignore ]   [ # 14 ]
Sr. Member
RankRankRankRank
Total Posts:  232
Joined  2008-11-05
David - 13 April 2009 09:36 PM

How shall I name starting ruby tags?

<% code %> 

I’d go with `delimiter.balanced.code.interpolated.begin` and `delimiter.balanced.code.interpolated.end` as the capture names, and the entire zone could be as simple as `container.interpolated.ruby` or something.

 Signature 

Ruby.sugar | Rails.sugar? | Haml.sugar | SASS.sugar | Sugar Manager.sugar | Git.sugar | Regex.sugar | ERb.sugar | RSpec.sugar

http://elliottcable.name/contact.xhtml

Profile
 
 
Posted: 13 April 2009 10:15 PM   [ Ignore ]   [ # 15 ]
Jr. Member
RankRank
Total Posts:  43
Joined  2008-10-29

Thanks, I’ll do that. :)

 Signature 

Markdown.sugar – The super-awesome Markdown for Espresso.

Profile