code-examples: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
m (Reverted edit of LrtSux, changed back to last version by RyanKing)
m (Reverted edits by TrtaeLordo (Talk) to last version by HikIqa)
 
(2 intermediate revisions by 2 users not shown)
Line 13: Line 13:
[http://lxr.mozilla.org/mozilla1.8/source/browser/app/nsBrowserApp.cpp Mozilla - LXR]
[http://lxr.mozilla.org/mozilla1.8/source/browser/app/nsBrowserApp.cpp Mozilla - LXR]


* uses <code>&lt;pre&gt;</code> to designate code block
* uses <code>
* composed of:
** Programming language inline at the top
** License is inline in comments in the code block
** Author is inline with the license
** the code block is further complicated by having line numbers
 
=== PHPClasses ===
[http://www.phpclasses.org/browse/file/10684.html PHPClasses - Viewing a file]
 
* uses table rows to encapsulate data regarding the file
* code is designated by <code>&lt;pre&gt;</code>
* composed of:
** File Name
** File Version
** Author Name
** Author Webpage
** Author Email
** License (inline)
** Content type
** Description
* license, author data, and programing languge version are located in the [http://www.phpclasses.org/browse/package/2544.html class data] as well as inline with the file
 
=== Php.net ===
[http://us3.php.net/ldap Php.net ldap functions]
 
* uses <code>&lt;div&gt;</code> to designate the code block
* Has an assumed free license, and no other metadata attached to the code
* code is a mess for syntax highlighting purposes
 
=== Bigbold snippets ===
[http://www.bigbold.com/snippets/posts/show/3346 A Python decorator]
 
* uses <code>&lt;pre&gt;</code> to designate the block of code
* source code is a mess to account for syntax highlighting
* composed of:
** Author
** Author webpage
** Programming language
 
=== Sun Java ===
[http://java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/ Java Code Samples]
 
* uses <code>&lt;pre&gt;</code> to designate the block of code
* source code is by and large plain text
* composed of:
** source code
** author's name
 
=== Java World ===
[http://www.javaworld.com/javaworld/jw-01-2007/jw-0102-games.html Java World Articles]
 
* user <code>&lt;pre&gt;&lt;code&gt;</code> to designate the block of code
* source code is mostly plain text
* composed of:
** Source code
** author's name
 
=== CodeHighlighter ===
[http://www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype CodeHightlighter] A syntax highlighter written in Javascript (can be used e.g. for code snippets in blogarticles). [http://svn.danwebb.net/external/CodeHighlighter/trunk/index.html Examples for markup (for CSS, HTML, Ruby code)]
 
* <code>&lt;pre&gt;&lt;code class="ruby"&gt;# ruby code&lt;/code&gt;&lt;/pre&gt;</code>
* source code is plain text
* composed of:
** programming language (designated through the class attribute)
 
=== ASPN ===
[http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/501154 Python Cookbook]
 
* uses <code>&lt;pre class="code"&gt;</code> to designate the block of code
* once again the source code is a mess to account for syntax highlighting
* composed of:
** Link to plain text version of source
** Title
** Submitter
** Last Updated
** Version no
** Category
** Description
* The language is again assumed from the location on the site
 
== Existing Practices ==
=== Common Patterns ===
 
* pre and code blocks are common wrappers around code blocks.
* Author, and various author details are commonly included.
* Descriptions, Titles, and the version of the supplied code are common elements
* License's are less common, and if the exist most commonly exist inline with the source code.
* Often times the language and version are to be assumed either by the type of site or the tags associated with that post.
 
=== Existing Solutions ===
 
* [http://www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype CodeHightlighter]:  Javascript syntax highlighter that attempts to maintain the semantic html structure of the code block without muddling it with styling. Designates the programming language of the code through the class attribute.
 
==See also==
*[http://www.asp-shareware.org/pad/ Portable Application Description] (PAD)
 
== Proposal ==
* Early drafts
** [[code-brainstorming]]

Latest revision as of 23:59, 17 December 2008

Code Examples

Per the microformats process this is an examples page documenting existing real world examples of source code published on the Web. Next steps are to research code-formats and then proceed with code-brainstorming.

The Problem

Source code is published around the web in nonstandard formats, this makes actual use more difficult as it a) obscures possible licensing issues, b) doesn't encapsulate the source code in standard machine readable formats, and c) doesn't keep important meta data such as authors, language types and language version, with the source code in a machine readable fashion.

Participants

Real-World Examples

LXR

Mozilla - LXR

  • uses