Template:CodeSample: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
imported>StDoodle
mNo edit summary
Line 28: Line 28:
}
}
</syntaxhighlight>}}
</syntaxhighlight>}}
==Read Me==
Please keep the following in mind when adding a code sample:
Please keep the following in mind when adding a code sample:
* Tabs display poorly in the <nowiki><syntaxhighlight></nowiki> tag. Please use 3 spaces, instead.
* Tabs display poorly in the <nowiki><syntaxhighlight></nowiki> tag. Please use 3 spaces, instead
** Yes, some people have other preferences; I'm not going to tell you how to write your own scripts.
** Yes, some people have other preferences; I'm not going to tell you how to write your own scripts
** In order to make the wiki as easy-to-use as possible, it's important to keep to ONE standard, please.
** In order to make the wiki as easy-to-use as possible, it's important to keep to ONE standard, please
* Please make sure there is one code sample (the 1st) that is as short & to-the-point as is possible.
* Please make sure there is one code sample (the 1st) that is as short & to-the-point as is possible.
* Please make sure that testing the code sample won't be significantly negative to the user; these are designed as hands-on examples.
* Please make sure that testing the code sample won't be significantly negative to the user; these are designed as hands-on examples
** For instance, if you must autosell items in the sample, choose something cheap.
** For instance, if you must autosell items in the sample, choose something cheap
** Do NOT include anything that could cause "permanent" damage!
** Do NOT include anything that could cause "permanent" damage!
* Please follow other conventions used on other code samples as much as possible (placement of {}, etc).
* Please follow other conventions used on other code samples as much as possible
* Do not modify a code sample purely to "add your own mark" to a page; if it illustrates the function, leave it be.
* Please avoid using cli_execute() if there is a built-in ash function
* Please note that incredibly long lines will break formatting on smaller screens; break things up if needed
* Do not modify a code sample purely to "add your own mark" to a page; if it illustrates the function, leave it be


[[Category:Basic Templates]]</noinclude>
[[Category:Basic Templates]]</noinclude>

Revision as of 00:35, 11 April 2010


Uses the named parameters title, description and code to display a code block & its information.

Note that only code is required; the title and description are optional.

A sample call to this template:

{{CodeSample|
title=Sample Code|
description=Some basic sample code.|
code=
<syntaxhighlight>
int i = 1; //this line is useless!
if (to_int(my_id()) > 1) {
   print("Aw, I guess you aren't Jick.");
}
</syntaxhighlight>
}}

Which produces the following:

Sample Code

Some basic sample code.

int i = 1; //this line is useless!
if (to_int(my_id()) > 1) {
   print("Aw, I guess you aren't Jick.");
}


Read Me

Please keep the following in mind when adding a code sample:

  • Tabs display poorly in the <syntaxhighlight> tag. Please use 3 spaces, instead
    • Yes, some people have other preferences; I'm not going to tell you how to write your own scripts
    • In order to make the wiki as easy-to-use as possible, it's important to keep to ONE standard, please
  • Please make sure there is one code sample (the 1st) that is as short & to-the-point as is possible.
  • Please make sure that testing the code sample won't be significantly negative to the user; these are designed as hands-on examples
    • For instance, if you must autosell items in the sample, choose something cheap
    • Do NOT include anything that could cause "permanent" damage!
  • Please follow other conventions used on other code samples as much as possible
  • Please avoid using cli_execute() if there is a built-in ash function
  • Please note that incredibly long lines will break formatting on smaller screens; break things up if needed
  • Do not modify a code sample purely to "add your own mark" to a page; if it illustrates the function, leave it be