Help:Source code fragment

Subversive Technologies & Countermeasures

Jump to: navigation, search

"Source fragments" are short pieces of source code usually created to illustrate pseudocode, language semantics, or functionality. These fragments are usually proof of concept code used to validate or explain concepts being discussed in content.

Contents

[edit] Creating source fragments

Source fragments should be created as separate sub pages of the article they will be originally referenced in. By making source fragments sub pages you allow others to reference your work in their works and maintain a single source file. Minor changes, bug fixes, or slight modifications will then be propagated to any works referencing the fragment. Some works might need a stable code base that will not be linked to a fragment that might evolve on a different path causing code or ideological conflicts in your work. In this case you should create a copy of the original fragment within your own work as a sub page and provide a link to the original source fragment in order to maintain original credit.

[edit] Source fragment information

Source fragment pages should contain a <noinclude> </noinclude> header containing any relevant information pertaining to the fragment.

[edit] Using source fragments

When using source fragments form other peoples works always:

  • Credit the original author(s).
  • Provide some type of link back to the original fragment page that contains its information header.

[edit] Transclusion of source fragments

  1. Transclude the source fragment by including {{:XXX}} in your page; Where XXX if the full name of the source fragment page to be transcluded.
  2. Add Template:Source code fragment link below the transcluded source fragment to allow access to the original fragment from your page.

Example:

Fragment displayed in article Wiki Text of fragment in page edit
void main() {
  printf("Hello Transcluded Source Fragment\n");
}
View source code fragment : Help:Source code fragment/Transcluded source code fragment
{{:Help:Source code fragment/Transcluded source code fragment}} {{Source code fragment link|Help:Source code fragment/Transcluded source code fragment}}


Helpdesk
Need more help? You can ask your questions at the Helpdesk
Personal tools