Template:File/Doc: Difference between revisions
Created page with "This template is used to display the content of a file, or otherwise a block of code with the context of which file it would belong to. {{file|main.py|| def main() pass if __name__ == "__main__" main() }} == Usage == <nowiki>{{file|filename|language|contents}}</nowiki> See documentation about <code><syntaxhighlight></code> for supported languages. <nowiki>{{file|main.c|c| #include <stdio.h> main( ) { printf("hello, world\n"); } }}</nowiki> == Ex..." |
m →Template data: remove aliases |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This template is used to display the content of a file, or otherwise a block of code with the context of which file it would belong to. | This template is used to display the content of a file, or otherwise a block of code with the context of which file it would belong to. | ||
{{file|main.py|| | {{file|main.py|py| | ||
def main() | <nowiki> | ||
def main(): | |||
pass | pass | ||
if __name__ == "__main__" | if __name__ == "__main__": | ||
main() | main() | ||
</nowiki> | |||
}} | }} | ||
== Usage == | == Usage == | ||
Simply include this template in your page, specifying the language, file name and content of the file. Note that you may have to surround the code in <code><<nowiki>nowiki</nowiki>></code> tags in order to display it correctly. | |||
{{code|lang=mediawiki|line=no|<nowiki> | |||
{{file|main.c|c| | |||
</nowiki><<nowiki>nowiki</nowiki>><nowiki> | |||
#include <stdio.h> | #include </nowiki><<nowiki>stdio.h</nowiki>><nowiki> | ||
main( ) | main( ) | ||
Line 22: | Line 24: | ||
printf("hello, world\n"); | printf("hello, world\n"); | ||
} | } | ||
</nowiki></<nowiki>nowiki</nowiki>><nowiki> | |||
}}</nowiki> | }}</nowiki> | ||
}} | |||
<includeonly> | |||
=== Template data === | |||
<templatedata> | |||
{ | { | ||
"description": "Display a block of code alongside the name of the file it would belong to", | |||
"params": { | |||
"name": { | |||
"label": "File name", | |||
"description": "Name of the file the code belongs to", | |||
"type": "string", | |||
"required": true | |||
}, | |||
"lang": { | |||
"label": "Programming language", | |||
"description": "The programming language used in the code", | |||
"type": "string", | |||
"required": true | |||
}, | |||
"3": { | |||
"label": "Content", | |||
"description": "The code to be displayed", | |||
"type": "string", | |||
"required": true | |||
}, | |||
"1": { | |||
"deprecated": true | |||
}, | |||
"2": { | |||
"deprecated": true | |||
}, | |||
"filename": { | |||
"deprecated": true | |||
}, | |||
"file": { | |||
"deprecated": true | |||
}, | |||
"contents": { | |||
"deprecated": true | |||
}, | |||
"language": { | |||
"deprecated": true | |||
} | |||
} | |||
} | } | ||
</templatedata></includeonly> |