Comment Syntax: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
m (add Bash)
 
(39 intermediate revisions by the same user not shown)
Line 1: Line 1:
程式的註解語法(Comment Syntax) << [[Testing]]
程式或網站服務設定檔的註解語法 (Comment syntax for programming languages or server configuration file) << [[Testing]]


== B: Bash shell ==
== A: Apache config ==
[https://httpd.apache.org/docs/2.4/configuring.html#syntax Configuration Files - Apache HTTP Server Version 2.4]
<pre>
# single line comment
</pre>
 
 
== B: Bash (shell script) ==
[http://en.wikipedia.org/wiki/Bash_(Unix_shell) Bash (Unix shell)]
[http://en.wikipedia.org/wiki/Bash_(Unix_shell) Bash (Unix shell)]
<pre>
<pre>
Line 7: Line 14:
</pre>
</pre>


==C: CSS==
== C: CSS, Cron ==
CSS Code: '''viewable''' when user view the HTML source code<ref>[http://www.w3schools.com/css/css_syntax.asp CSS Syntax]</ref>
CSS Code: '''viewable''' when user view the HTML source code<ref>[http://www.w3schools.com/css/css_syntax.asp CSS Syntax]</ref>
<pre>
<pre>
Line 17: Line 24:
[http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx Conditional Comments] for {{IE}}
[http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx Conditional Comments] for {{IE}}


==D: DOS==
[https://zh.wikipedia.org/wiki/Cron Cron] jobs code<ref>[https://www.webhostingtalk.com/showthread.php?t=619350 How to comment cron job? | Web Hosting Talk]</ref>
<pre>
# single line
# 0 0 * * 0 execute some script weekly
</pre>
 
==D: DOS, Dockerfile ==
DOS Command Code<ref>[http://www.csulb.edu/~murdock/rem.html DOS Command:  REM]</ref>:
DOS Command Code<ref>[http://www.csulb.edu/~murdock/rem.html DOS Command:  REM]</ref>:
<pre>
<pre>
REM [comment]
REM [comment]
ex: REM single line comment
ex: REM single line comment
</pre>
Dockerfile or [https://docs.docker.com/compose/compose-file/ compose file] (docker-compose.yml)
<pre>
# single line comment
</pre>
</pre>


Line 33: Line 52:
</pre>
</pre>


==J: Javascript, JSP==
==J: Javascript, Java, JSP==
Javascript Code: '''viewable''' when user view the HTML source code
Javascript Code: '''viewable''' when user view the HTML source code
<pre>
<pre>
Line 44: Line 63:




JSP<ref>[http://www.xyzws.com/JSPfaq/how-to-use-comments-in-jsp-pages/8 How to use comments in JSP pages?]</ref>
Java<ref>[http://www.oracle.com/technetwork/articles/java/index-137868.html How to Write Doc Comments for the Javadoc Tool]</ref> & JSP<ref>[http://www.xyzws.com/JSPfaq/how-to-use-comments-in-jsp-pages/8 How to use comments in JSP pages?]</ref>
<pre>
<pre>
//single line comment
//single line comment
Line 53: Line 72:
</pre>
</pre>


==P: Perl, PHP, Python==
== M: MySQL ==
MySQL configuration file
<pre>
# single line comment
 
-- single line comment. Note there are one space between '--' with 'single line comment'.
 
/* multiple
  lines
  comments
*/
</pre>
 
==P: Perl, PHP, Postman, Python==
Perl Code<ref>[http://www.tizag.com/perlT/perlsyntax.php perl - syntax]</ref>:
Perl Code<ref>[http://www.tizag.com/perlT/perlsyntax.php perl - syntax]</ref>:
<pre>
<pre>
#single line comment
# single line comment
</pre>
</pre>


Line 76: Line 108:
</pre>
</pre>


Python: [http://ipython.org/notebook.html The IPython Notebook]<ref>[http://nbviewer.ipython.org/urls/raw.github.com/ricardoduarte/python-for-developers/master/Chapter2/Chapter2_Syntax.ipynb Python for Developers - Chapter 2: Syntax]</ref>
Postman<ref>[https://github.com/postmanlabs/postman-app-support/issues/3358 Feature request: Raw body editor JSON comment · Issue #3358 · postmanlabs/postman-app-support · GitHub]</ref>
<pre>
// single line comment
</pre>
 
Python: [http://ipython.org/notebook.html The IPython Notebook]<ref>[http://nbviewer.ipython.org/urls/raw.github.com/ricardoduarte/python-for-developers/master/Chapter2/Chapter2_Syntax.ipynb Python for Developers - Chapter 2: Syntax]</ref><ref>[http://stackoverflow.com/questions/7696924/multiline-comments-in-python Multiline comments in Python - Stack Overflow]</ref>
<pre>
<pre>
# single line comment
# single line comment
</pre>


<pre>
'''
This is the multiline
comments.
'''
</pre>
</pre>
== R ==
[https://www.r-project.org/ R: The R Project for Statistical Computing]: [https://google.github.io/styleguide/Rguide.xml#comments Commenting Guidelines]
<pre>
# single line comment
</pre>
Multiline lines comment : Use [https://www.rstudio.com/ RStudio] ([https://support.rstudio.com/hc/en-us/articles/200484448-Editing-and-Executing-Code Editing and Executing Code – RStudio Support]) to comment/uncomment the selected code. [http://stackoverflow.com/questions/1231195/multiline-comment-workarounds r - Multiline Comment Workarounds? - Stack Overflow]


==S: SIKULI, SQL==
==S: SIKULI, SQL==
[http://groups.csail.mit.edu/uid/sikuli/ SIKULI] Code:
[http://groups.csail.mit.edu/uid/sikuli/ SIKULI] Code: ({{exclaim}} multiple line comment is not supported for SIKULI IDE 1.x[https://bugs.launchpad.net/sikuli/+bug/585342])
<pre>
<pre>
#single line comment
# single line comment
</pre>
</pre>


Line 116: Line 168:
further reading
further reading
* [http://blog.csdn.net/haoel/article/details/5782907 五種應該避免的代碼注釋 - 陳皓專欄](簡體)
* [http://blog.csdn.net/haoel/article/details/5782907 五種應該避免的代碼注釋 - 陳皓專欄](簡體)
 
* [https://en.wikipedia.org/wiki/Comment_(computer_programming) Comment (computer programming) - Wikipedia, the free encyclopedia]
* [https://phpunit.de/manual/current/en/appendixes.annotations.html PHPUnit Manual – Appendix B. Annotations]


[[Category:Web_Dev]] [[Category:Programming]]
[[Category:Web_Dev]] [[Category:Programming]]

Latest revision as of 14:24, 28 March 2022

程式或網站服務設定檔的註解語法 (Comment syntax for programming languages or server configuration file) << Testing

A: Apache config[edit]

Configuration Files - Apache HTTP Server Version 2.4

# single line comment


B: Bash (shell script)[edit]

Bash (Unix shell)

# single line comment

C: CSS, Cron[edit]

CSS Code: viewable when user view the HTML source code[1]

/* multiple lines
comments
*/

Conditional Comments for IE Browser msie.png

Cron jobs code[2]

# single line
# 0 0 * * 0 execute some script weekly

D: DOS, Dockerfile[edit]

DOS Command Code[3]:

REM [comment]
ex: REM single line comment

Dockerfile or compose file (docker-compose.yml)

# single line comment

H: HTML[edit]

HTML Code: viewable when user view the HTML source code

<!-- This is an HTML Comment -->

<!-- multiple 
lines -->

J: Javascript, Java, JSP[edit]

Javascript Code: viewable when user view the HTML source code

//single line comment

/* multiple 
lines
*/


Java[4] & JSP[5]

//single line comment

/* multiple 
lines
*/

M: MySQL[edit]

MySQL configuration file

# single line comment

-- single line comment. Note there are one space between '--' with 'single line comment'.

/* multiple
   lines
   comments
*/

P: Perl, PHP, Postman, Python[edit]

Perl Code[6]:

# single line comment


PHP Code: not viewable when user view the HTML source code[7]

# single line comment
// another single line comment

/* multiple 
lines
*/


php.ini

; single line comment

Postman[8]

// single line comment

Python: The IPython Notebook[9][10]

# single line comment
'''
This is the multiline
comments.
'''

R[edit]

R: The R Project for Statistical Computing: Commenting Guidelines

# single line comment

Multiline lines comment : Use RStudio (Editing and Executing Code – RStudio Support) to comment/uncomment the selected code. r - Multiline Comment Workarounds? - Stack Overflow

S: SIKULI, SQL[edit]

SIKULI Code: (Icon_exclaim.gif multiple line comment is not supported for SIKULI IDE 1.x[1])

# single line comment

SQL Command / MySQL 5.1 Comment Syntax:

-- single line comment

/* multiple 
lines
*/

V: VBScript[edit]

VBScript Coding Conventions, VBScript Tutorial - Operators

' single line comment

X: XML[edit]

XML Code[11] [12]:

<!--
	multiple lines
-->

References

further reading