Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/Documentation
note: Software Engineering

View file

@ -0,0 +1,7 @@
Show how to insert documentation for classes, functions, and/or variables in your language. If this documentation is built-in to the language, note it. If this documentation requires external tools, note them.
;See also:
* Related task: [[Comments]]
* Related task: [[Here_document]]
<br><br>

View file

@ -0,0 +1,25 @@
with Ada.Text_Io; use Ada.Text_Io;
generic
SortName : in String;
type DataType is (<>);
type SortArrayType is array (Integer range <>) of DataType;
with procedure Sort (SortArray : in out SortArrayType;
Comp, Write, Ex : in out Natural);
package Instrument is
-- This generic package essentially accomplishes turning the sort
-- procedures into first-class functions for this limited purpose.
-- Obviously it doesn't change the way that Ada works with them;
-- the same thing would have been much more straightforward to
-- program in a language that had true first-class functions
package Dur_Io is new Fixed_Io(Duration);
procedure TimeSort (Arr : in out SortArrayType);
procedure Put;
procedure Put (File : in out File_Type);
end Instrument;

View file

@ -0,0 +1,13 @@
f: function [x :integer, y :integer][
;; description: « takes two integers and adds them up
;; options: [
;; double: « also multiply by two
;; ]
;; returns: :integer
result: x+y
if not? null? attr 'double -> result: result * 2
return result
]
info'f

View file

@ -0,0 +1,17 @@
;
; Function: example_add
; Description:
; Adds two or three numbers (see [url=http://en.wikipedia.org/Number]Number [/url])
; Syntax: example_add(number1, number2[, number3=0])
; Parameters:
; number1 - First number to add.
; number2 - Second number to add.
; number3 - (Optional) Third number to add. You can just omit this parameter.
; Return Value:
; sum of parameters
; Example:
; MsgBox % example_add(example_add(2, 3, 4), 5)
;
example_add(number1, number2, number3=0){
return number1 + number2 + number3
}

View file

@ -0,0 +1,20 @@
/// <summary>
/// The XMLSystem class is here to help handle XML items in this site.
/// </summary>
public static class XMLSystem
{
static XMLSystem()
{
// Constructor
}
/// <summary>
/// A function to get the contents of an XML document.
/// </summary>
/// <param name="name">A valid name of an XML document in the data folder</param>
/// <returns>An XmlDocument containing the contents of the XML file</returns>
public static XmlDocument GetXML(string name)
{
return null;
}
}

View file

@ -0,0 +1,13 @@
/**
* \brief Perform addition on \p a and \p b.
*
* \param a One of the numbers to be added.
* \param b Another number to be added.
* \return The sum of \p a and \p b.
* \code
* int sum = add(1, 2);
* \endcode
*/
int add(int a, int b) {
return a + b;
}

View file

@ -0,0 +1,57 @@
*>****L* cobweb/cobweb-gtk [0.2]
*> Author:
*> Author details
*> Colophon:
*> Part of the GnuCobol free software project
*> Copyright (C) 2014 person
*> Date 20130308
*> Modified 20141003
*> License GNU General Public License, GPL, 3.0 or greater
*> Documentation licensed GNU FDL, version 2.1 or greater
*> HTML Documentation thanks to ROBODoc --cobol
*> Purpose:
*> GnuCobol functional bindings to GTK+
*> Main module includes paperwork output and self test
*> Synopsis:
*> |dotfile cobweb-gtk.dot
*> |html <br />
*> Functions include
*> |exec cobcrun cobweb-gtk >cobweb-gtk.repository
*> |html <pre>
*> |copy cobweb-gtk.repository
*> |html </pre>
*> |exec rm cobweb-gtk.repository
*> Tectonics:
*> cobc -v -b -g -debug cobweb-gtk.cob voidcall_gtk.c
*> `pkg-config --libs gtk+-3.0` -lvte2_90 -lyelp
*> robodoc --cobol --src ./ --doc cobwebgtk --multidoc --rc robocob.rc --css cobodoc.css
*> cobc -E -Ddocpass cobweb-gtk.cob
*> make singlehtml # once Sphinx set up to read cobweb-gtk.i
*> Example:
*> COPY cobweb-gtk-preamble.
*> procedure division.
*> move TOP-LEVEL to window-type
*> move 640 to width-hint
*> move 480 to height-hint
*> move new-window("window title", window-type,
*> width-hint, height-hint)
*> to gtk-window-data
*> move gtk-go(gtk-window) to extraneous
*> goback.
*> Notes:
*> The interface signatures changed between 0.1 and 0.2
*> Screenshot:
*> image:cobweb-gtk1.png
*> Source:
REPLACE ==FIELDSIZE== BY ==80==
==AREASIZE== BY ==32768==
==FILESIZE== BY ==65536==.
id identification division.
program-id. cobweb-gtk.
...
done goback.
end program cobweb-gtk.
*>****

View file

@ -0,0 +1,16 @@
>>IF docpass NOT DEFINED
... code ...
>>ELSE
!doc-marker!
========
:SAMPLE:
========
.. contents::
Introduction
------------
ReStructuredText or other markup source ...
>>END-IF

View file

@ -0,0 +1,7 @@
(def
#^{:doc "Metadata can contain documentation and can be added to vars like this."}
test1)
(defn test2
"defn and some other macros allow you add documentation like this. Works the same way"
[])

View file

@ -0,0 +1,14 @@
# Any block of comments *directly* before (no blank lines) a module, class, or method is used as a doc comment
# This one is for a module
module Documentation
# This comment documents a class, *and* it uses markdown
class Foo
# This comment doesn't do anything, because it isn't directly above a module, class, or method
# Finally, this comment documents a method
def initialize
end
end
end

View file

@ -0,0 +1,42 @@
/**
This is a documentation comment for someFunc and someFunc2.
$(DDOC_COMMENT comment inside a documentation comment
(results in a HTML comment not displayed by the browser))
Header:
content (does not need to be tabbed out; this is done for clarity
of the comments and has no effect on the resulting documentation)
Params:
arg1 = Something (listed as "int <i>arg1</i> Something")
arg2 = Something else
Returns:
Nothing
TODO:
Nothing at all
BUG:
None found
*/
void someFunc(int arg1, int arg2) {}
// This groups this function with the above (both have the
// same doc and are listed together)
/// ditto
void someFunc2(int arg1, int arg2) {}
/// Sum function.
int sum(in int x, in int y) pure nothrow {
return x + y;
}
// These unittests will become part of sum documentation:
///
unittest {
assert(sum(2, 3) == 5);
}
/++ Another documentation comment +/
void main() {}

View file

@ -0,0 +1,10 @@
type
/// <summary>Sample class.</summary>
TMyClass = class
public
/// <summary>Converts a string into a number.</summary>
/// <param name="aValue">String parameter</param>
/// <returns>Numeric equivalent of aValue</returns>
/// <exception cref="EConvertError">aValue is not a valid integer.</exception>
function StringToNumber(aValue: string): Integer;
end;

View file

@ -0,0 +1,8 @@
? /** This is an object with documentation */
> def foo {
> # ...
> }
# value: <foo>
? foo.__getAllegedType().getDocComment()
# value: " This is an object with documentation "

View file

@ -0,0 +1,88 @@
note
description: "Objects that model Times of Day: 00:00:00 - 23:59:59"
author: "Eiffel Software Construction Students"
class
TIME_OF_DAY
create
make
feature -- Initialization
make
-- Initialize to 00:00:00
do
hour := 0
minute := 0
second := 0
ensure
initialized: hour = 0 and
minute = 0 and
second = 0
end
feature -- Access
hour: INTEGER
-- Hour expressed as 24-hour value
minute: INTEGER
-- Minutes past the hour
second: INTEGER
-- Seconds past the minute
feature -- Element change
set_hour (h: INTEGER)
-- Set the hour from `h'
require
argument_hour_valid: 0 <= h and h <= 23
do
hour := h
ensure
hour_set: hour = h
minute_unchanged: minute = old minute
second_unchanged: second = old second
end
set_minute (m: INTEGER)
-- Set the minute from `m'
require
argument_minute_valid: 0 <= m and m <= 59
do
minute := m
ensure
minute_set: minute = m
hour_unchanged: hour = old hour
second_unchanged: second = old second
end
set_second (s: INTEGER)
-- Set the second from `s'
require
argument_second_valid: 0 <= s and s <= 59
do
second := s
ensure
second_set: second = s
hour_unchanged: hour = old hour
minute_unchanged: minute = old minute
end
feature {NONE} -- Implementation
protected_routine
-- A protected routine (not available to client classes)
-- Will not be present in documentation (Contract) view
do
end
invariant
hour_valid: 0 <= hour and hour <= 23
minute_valid: 0 <= minute and minute <= 59
second_valid: 0 <= second and second <= 59
end -- class TIME_OF_DAY

View file

@ -0,0 +1,63 @@
note
description: "Objects that model Times of Day: 00:00:00 - 23:59:59"
author: "Eiffel Software Construction Students"
class interface
TIME_OF_DAY
create
make
feature -- Initialization
make
-- Initialize to 00:00:00
ensure
initialized: hour = 0 and minute = 0 and second = 0
feature -- Access
hour: INTEGER_32
-- Hour expressed as 24-hour value
minute: INTEGER_32
-- Minutes past the hour
second: INTEGER_32
-- Seconds past the minute
feature -- Element change
set_hour (h: INTEGER_32)
-- Set the hour from `h'
require
argument_hour_valid: 0 <= h and h <= 23
ensure
hour_set: hour = h
minute_unchanged: minute = old minute
second_unchanged: second = old second
set_minute (m: INTEGER_32)
-- Set the minute from `m'
require
argument_minute_valid: 0 <= m and m <= 59
ensure
minute_set: minute = m
hour_unchanged: hour = old hour
second_unchanged: second = old second
set_second (s: INTEGER_32)
-- Set the second from `s'
require
argument_second_valid: 0 <= s and s <= 59
ensure
second_set: second = s
hour_unchanged: hour = old hour
minute_unchanged: minute = old minute
invariant
hour_valid: 0 <= hour and hour <= 23
minute_valid: 0 <= minute and minute <= 59
second_valid: 0 <= second and second <= 59
end -- class TIME_OF_DAY

View file

@ -0,0 +1,8 @@
def project do
[app: :repo
version: "0.1.0-dev",
name: "REPO",
source_url: "https://github.com/USER/REPO",
homepage_url: "http://YOUR_PROJECT_HOMEPAGE"
deps: deps]
end

View file

@ -0,0 +1,10 @@
defmodule MyModule do
@moduledoc """
About MyModule
## Some Header
iex> MyModule.my_function
:result
"""
end

View file

@ -0,0 +1,3 @@
(defun hello (n)
"Say hello to the user."
(message "hello %d" n))

View file

@ -0,0 +1,2 @@
(defvar one-hundred 100
"The number one hundred.")

View file

@ -0,0 +1,13 @@
def class Foo {
"""
This is a docstring. Every object in Fancy can have it's own docstring.
Either defined in the source code, like this one, or by using the Object#docstring: method
"""
def a_method {
"""
Same for methods. They can have docstrings, too.
"""
}
}
Foo docstring println # prints docstring Foo class
Foo instance_method: 'a_method . docstring println # prints method's docstring

View file

@ -0,0 +1 @@
\ this is a comment

View file

@ -0,0 +1 @@
: cubed ( n -- n^3 ) dup dup * * ;

View file

@ -0,0 +1,3 @@
SUBROUTINE SHOW(A,N) !Prints details to I/O unit LINPR.
REAL*8 A !Distance to the next node.
INTEGER N !Number of the current node.

View file

@ -0,0 +1,25 @@
// Example serves as an example but does nothing useful.
//
// A package comment preceeds the package clause and explains the purpose
// of the package.
package example
// Exported variables.
var (
// lookie
X, Y, Z int // popular names
)
/* XP does nothing.
Here's a block comment. */
func XP() { // here we go!
// comments inside
}
// Non-exported.
func nonXP() {}
// Doc not extracted.
var MEMEME int

View file

@ -0,0 +1,6 @@
`My Hello Message'
Print a greeting to the user.
This is only a short greeting.
{
show "hello"
}

View file

@ -0,0 +1 @@
help My Hello Message

View file

@ -0,0 +1,26 @@
-- |This is a documentation comment for the following function
square1 :: Int -> Int
square1 x = x * x
-- |It can even
-- span multiple lines
square2 :: Int -> Int
square2 x = x * x
square3 :: Int -> Int
-- ^You can put the comment underneath if you like, like this
square3 x = x * x
{-|
Haskell block comments
are also supported
-}
square4 :: Int -> Int
square4 x = x * x
-- |This is a documentation comment for the following datatype
data Tree a = Leaf a | Node [Tree a]
-- |This is a documentation comment for the following type class
class Foo a where
bar :: a

View file

@ -0,0 +1,25 @@
############################################################################
#
# File: filename.icn
#
# Subject: Short Description
#
# Author: Author's name
#
# Date: Date
#
############################################################################
#
# This file is in the public domain. (or other license)
#
############################################################################
#
# Long form docmentation
#
############################################################################
#
# Links:
#
############################################################################
procedure x1() #: short description of procedure

View file

@ -0,0 +1,26 @@
theory Text
imports Main
begin
chapter Presenting Theories
text This text will appear in the proof document.
section Some Examples.
A marginal comment. The expression \<^term>True holds.
lemma True_is_True: "True" ..
text
The overall content of an Isabelle/Isar theory may alternate between formal
and informal text.
text_raw Can also contain raw latex.
text This text will only compile if the fact @{thm True_is_True} holds.
text This text will only compile if the constant \<^const>True is defined.
end

View file

@ -0,0 +1,24 @@
NB. =========================================================
NB.*apply v apply verb x to y
apply=: 128!:2
NB. =========================================================
NB.*def c : (explicit definition)
def=: :
NB.*define a : 0 (explicit definition script form)
define=: : 0
NB.*do v name for ".
do=: ".
NB.*drop v name for }.
drop=: }.
Note 1
Note accepts multi-line descriptions.
Definitions display the source.
)
usleep
3 : '''libc.so.6 usleep > i i''&(15!:0) >.y'

View file

@ -0,0 +1,22 @@
/**
* This is a class documentation comment. This text shows at the top of the page for this class
* @author Joe Schmoe
*/
public class Doc{
/**
* This is a field comment for a variable
*/
private String field;
/**
* This is a method comment. It has parameter tags (param), an exception tag (throws),
* and a return value tag (return).
*
* @param num a number with the variable name "num"
* @throws BadException when something bad happens
* @return another number
*/
public int method(long num) throws BadException{
//...code here
}
}

View file

@ -0,0 +1,2 @@
"Tell whether there are too foo items in the array."
foo(xs::Array) = ...

View file

@ -0,0 +1,15 @@
"""
bar(x[, y])
Compute the Bar index between `x` and `y`. If `y` is missing, compute
the Bar index between all pairs of columns of `x`.
# Examples
```julia-repl
julia> bar([1, 2], [1, 2])
1
```
"""
function bar(x, y) ...

View file

@ -0,0 +1,19 @@
/**
* A group of *members*.
* @author A Programmer.
* @since version 1.1.51.
*
* This class has no useful logic; it's just a documentation example.
*
* @param T the type of a member in this group.
* @property name the name of this group.
* @constructor Creates an empty group.
*/
class Group<T>(val name: String) {
/**
* Adds a [member] to this group.
* @throws AddException if the member can't be added.
* @return the new size of the group.
*/
fun add(member: T): Int { ... }
}

View file

@ -0,0 +1,9 @@
'{def add // define the name
{lambda {:a :b} // for a function with two arguments
{+ :a :b} // whose body calls the + primitive on them
} // end function
} // end define
-> add
'{add 3 4} // call the function on two values
-> 7 // the result

View file

@ -0,0 +1,25 @@
:- object(set(_Type),
extends(set)).
% the info/1 directive is the main directive for documenting an entity
% its value is a list of Key-Value pairs; the set of keys is user-extendable
:- info([
version is 1.2,
author is 'A. Coder',
date is 2013/10/13,
comment is 'Set predicates with elements constrained to a single type.',
parnames is ['Type']
]).
% the info/2 directive is the main directive for documenting predicates
% its second value is a list of Key-Value pairs; the set of keys is user-extendable
:- public(intersection/3).
:- mode(intersection(+set, +set, ?set), zero_or_one).
:- info(intersection/3, [
comment is 'Returns the intersection of Set1 and Set2.',
argnames is ['Set1', 'Set2', 'Intersection']
]).
...
:- end_object.

View file

@ -0,0 +1,6 @@
--- Converts degrees to radians (summary).
-- Given an angle measure in degrees, return an equivalent angle measure in radians (long description).
-- @param deg the angle measure in degrees
-- @return the angle measure in radians
-- @see rad2deg
function deg2rad(deg) return deg*math.pi/180 end

View file

@ -0,0 +1,3 @@
function Gnash(GnashFile); %Convert to a "function". Data is placed in the "global" area.
% My first MatLab attempt, to swallow data as produced by Gnash's DUMP
%command in a comma-separated format. Such files start with a line

View file

@ -0,0 +1,5 @@
f[x_,y_] := x + y (* Function comment : adds two numbers *)
f::usage = "f[x,y] gives the sum of x and y"
?f
-> f[x,y] gives the sum of x and y

View file

@ -0,0 +1 @@
/** ... **/

View file

@ -0,0 +1 @@
<doc> ... </doc>

View file

@ -0,0 +1,5 @@
/**
result_set_conv_date : 'result -> function:1 -> void
<doc>Set the function that will convert a Date or DateTime string
to the corresponding value.</doc>
**/

View file

@ -0,0 +1,31 @@
## Nim directly supports documentation using comments that start with two
## hashes (##). To create the documentation run ``nim doc file.nim``.
## ``nim doc2 file.nim`` is the same, but run after semantic checking, which
## allows it to process macros and output more information.
##
## These are the comments for the entire module. We can have long descriptions
## here. Syntax is reStructuredText. Only exported symbols (*) get
## documentation created for them.
##
## Here comes a code block inside our documentation:
##
## .. code-block:: nim
## var inputStrings : seq[string]
## newSeq(inputStrings, 3)
## inputStrings[0] = "The fourth"
## inputStrings[1] = "assignment"
## inputStrings[2] = "would crash"
## #inputStrings[3] = "out of bounds"
type TPerson* = object
## This type contains a description of a person
name: string
age: int
var numValues*: int ## \
## `numValues` stores the number of values
proc helloWorld*(times: int) =
## A useful procedure
for i in 1..times:
echo "hello world"

View file

@ -0,0 +1,9 @@
#~
Sets the named row value
@param name name
@param value value
@return true of value was set, false otherwise
~#
method : public : Set(name : String, value : String) ~ Bool {
return Set(@table->GetRowId(name), value);
}

View file

@ -0,0 +1,11 @@
/*!
@function add
@abstract Adds two numbers
@discussion Use add to sum two numbers.
@param a an integer.
@param b another integer.
@return the sum of a and b
*/
int add(int a, int b) {
return a + b;
}

View file

@ -0,0 +1,16 @@
; note: use this script to generate a markdown file
; sed -n 's/\s*;!\s*//gp'
(import (owl parse))
;! # Documentation
;! ## Functions
;! ### whitespace
;! Returns a #true if argument is a space, newline, return or tab character.
(define whitespace (byte-if (lambda (x) (has? '(#\tab #\newline #\space #\return) x))))
;! ### maybe-whitespaces
;! Returns any amount (including 0) of whitespaces. Used as whitespace characters skipper in parses.
(define maybe-whitespaces (greedy* whitespace))

View file

@ -0,0 +1 @@
addhelp(funcName, "funcName(v, n): This is a description of the function named funcName.");

View file

@ -0,0 +1,12 @@
(phixonline)-->
<span style="color: #008080;">procedure</span> <span style="color: #000000;">StoreVar</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">N</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">NTyp</span><span style="color: #0000FF;">)</span>
<span style="color: #000080;font-style:italic;">--
-- Store a variable, applying any final operator as needed.
-- If N is zero, PopFactor (ie store in a new temporary variable of
-- the specified type). Otherwise N should be an index to symtab.
-- If storeConst is 1, NTyp is ignored/overridden, otherwise it
-- should usually be the declared or local type of N.
-- </span>
<span style="color: #0000FF;">...</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<!--

View file

@ -0,0 +1,5 @@
: (doc 'car) # View documentation of a function
: (doc '+Entity) # View documentation of a class
: (doc '+ 'firefox) # Explicitly specify a browser

View file

@ -0,0 +1 @@
help about_comment_based_help

View file

@ -0,0 +1,35 @@
; This is a small demo-code to demonstrate PureBasics internal
; documentation system.
;- All Includes
; By starting the line with ;- marks that specific line as a special comment,
; and this will be included in the overview, while normal comments will not.
IncludeFile "MyLibs.pbi"
IncludeFile "Combustion_Data.pbi"
;-
;- Start of functions and Macros
;- Engeneering stuff
; A small function to calculate gas properties
Procedure.f CalcR( p.f, V.f, T.f)
ProcedureReturn p*V/T
EndProcedure
; Example of a Macro
; These are indicated by '+' in the overview
Macro HalfPI()
(#PI/2)
EndMacro
;-
;- - - - - - - - - - -
;- IO-Functions
Procedure Write_and_Close( File, Text$)
If IsFile(File)
WriteString(File,Text$)
CloseFile(file)
EndIf
EndProcedure

View file

@ -0,0 +1,8 @@
class Doc(object):
"""
This is a class docstring. Traditionally triple-quoted strings are used because
they can span multiple lines and you can include quotation marks without escaping.
"""
def method(self, num):
"""This is a method docstring."""
pass

View file

@ -0,0 +1,11 @@
>>> def somefunction():
"takes no args and returns None after doing not a lot"
>>> help(somefunction)
Help on function somefunction in module __main__:
somefunction()
takes no args and returns None after doing not a lot
>>>

View file

@ -0,0 +1 @@
example(package.skeleton)

View file

@ -0,0 +1,59 @@
\name{f}
\Rdversion{1.1}
\alias{f}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
%% ~~function to do ... ~~
}
\description{
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
f(x, y)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
%% ~~Describe \code{x} here~~
}
\item{y}{
%% ~~Describe \code{y} here~~
}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(x,y) x+y
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line

View file

@ -0,0 +1,64 @@
REBOL [
Title: "Documentation"
URL: http://rosettacode.org/wiki/Documentation
Purpose: {To demonstrate documentation of REBOL pograms.}
]
; Notice the fields in the program header. The header is required for
; valid REBOL programs, although the fields don't have to be filled
; in. Standard fields are defined (see 'system/script/header'), but
; I can also define other fields as I like and they'll be available
; there.
; This is a comment. The semicolon can be inserted anywhere outside of
; a string and will escape to end of line. See the inline comments
; below.
; Functions can have a documentation string as the first part of the
; argument definition block. Each argument can specify what types it
; will accept as well as a description. All typing/documentation
; entries are optional. Notice that local variables can be documented
; as well.
sum: func [
"Add numbers in block."
data [block! list!] "List of numbers to add together."
/average "Calculate average instead of sum."
/local
i "Iteration variable."
x "Variable to hold results."
] [
x: 0 repeat i data [x: x + i]
either average [x / length? data][x] ; Functions return last result.
]
print [sum [1 2 3 4 5 6] crlf sum/average [7 8 9 10] crlf]
; The help message is constructed from the public information about
; the function. Internal variable information isn't shown.
help sum print ""
; The source command provides the source to any user functions,
; reconstructing the documentation strings if they're provided:
source sum print ""
; This is an object, describing a person, whose name is Bob.
bob: make object! [
name: "Bob Sorkopath"
age: 24
hi: func ["Say hello."][print "Hello!"]
]
; I can use the 'help' word to get a list of the fields of the object
help bob print ""
; If I want see the documentation or source for 'bob/hi', I have to
; get a little tricky to get it from the object's namespace:
x: get in bob 'hi help x print ""
probe get in bob 'hi

View file

@ -0,0 +1,29 @@
/*REXX program illustrates how to display embedded documentation (help) within REXX code*/
parse arg doc /*obtain (all) the arguments from C.L. */
if doc='?' then call help /*show documentation if arg=a single ? */
/*■■■■■■■■■regular■■■■■■■■■■■■■■■■■■■■■■■■■*/
/*■■■■■■■■■■■■■■■■■mainline■■■■■■■■■■■■■■■■*/
/*■■■■■■■■■■■■■■■■■■■■■■■■■■code■■■■■■■■■■■*/
/*■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■here.■■■■■*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
help: ?=0; do j=1 for sourceline(); _=sourceline(j) /*get a line of source.*/
if _='<help>' then do; ?=1; iterate; end /*search for <help> */
if _='</help>' then leave /* " " </help> */
if ? then say _
end /*j*/
exit /*stick a fork in it, we're all done. */
/*══════════════════════════════════start of the in═line documentation AFTER the <help>
<help>
To use the YYYY program, enter one of:
YYYY numberOfItems
YYYY (no arguments uses the default)
YYYY ? (to see this documentation)
where: numberOfItems is the number of items to be used.
If no "numberOfItems" are entered, the default of 100 is used.
</help>
end of the inline documentation BEFORE the </help> */

View file

@ -0,0 +1,19 @@
/* REXX ***************************************************************
* 13.10.2013 Walter Pachl another way to show documentation
* no tags and good enough if only one documentation block
**********************************************************************/
beghelp=here()+1 /* line where the docmentation begins
Documentation
any text explaining the program's invocation and workings
---
and where it ends */
endhelp=here()-2
If arg(1)='?' Then Do
Do i=beghelp To endhelp
Say sourceline(i)
End
Exit
End
say 'the program would be here!'
Exit
here: return sigl /* returns the invocation's line number */

View file

@ -0,0 +1,7 @@
#lang scribble/manual
(require (for-label "sandwiches.rkt"))
@defproc[(make-sandwich [ingredients (listof ingredient?)])
sandwich?]{
Returns a sandwich given the right ingredients.
}

View file

@ -0,0 +1,11 @@
#= it's yellow
sub marine { ... }
say &marine.WHY; # "it's yellow"
#= a shaggy little thing
class Sheep {
#= not too scary
method roar { 'roar!' }
}
say Sheep.WHY; # "a shaggy little thing"
say Sheep.^find_method('roar').WHY; # "not too scary"

View file

@ -0,0 +1,28 @@
# Determine The Average Word Name Length
To determine the average length of a word name two values
are needed. First, the total length of all names in the
Dictionary:
~~~
#0 [ d:name s:length + ] d:for-each
~~~
And then the number of words in the Dictionary:
~~~
#0 [ drop n:inc ] d:for-each
~~~
With these, a simple division is all that's left.
~~~
/
~~~
Finally, display the results:
~~~
'Average_name_length:_%n\n s:format s:put
~~~

View file

@ -0,0 +1,9 @@
/*
Multiply two numbers
n1: an integer.
n2: an integer.
returns product of n1 and n2
*/
see mult(3, 5) + nl
func mult n1, n2
return n1*n2

View file

@ -0,0 +1,35 @@
=begin rdoc
RDoc is documented here[http://www.ruby-doc.org/core/classes/RDoc.html].
This is a class documentation comment. This text shows at the top of the page
for the class.
Comments can be written inside "=begin rdoc"/"end" blocks or
in normal '#' comment blocks.
There are no '@parameters' like javadoc, but 'name-value' lists can be written:
Author:: Joe Schmoe
Date:: today
=end
class Doc
# This is a comment for a Constant
Constant = nil
# This is a method comment. Parameters and return values can be named
# with the "call-seq" directive.
#
# call-seq:
# a_method(first_arg, second_arg) -> return_value
#
def a_method(arg1, arg2='default value')
do_stuff
end
# Class methods will be shown in a separate section of the generated documentation.
def self.class_method
Constant
end
end
# :include:boilerplate.txt

View file

@ -0,0 +1,57 @@
//! Documentation for the module
//!
//! **Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Aenean a
//! sagittis sapien, eu pellentesque ex. Nulla facilisi. Praesent eget sapien
//! sollicitudin, laoreet ipsum at, fringilla augue. In hac habitasse platea
//! dictumst. Nunc in neque sed magna suscipit mattis sed quis mi. Curabitur
//! quis mi a ante mollis commodo. Sed tincidunt ut metus vel accumsan.
#![doc(html_favicon_url = "https://example.com/favicon.ico")]
#![doc(html_logo_url = "https://example.com/logo.png")]
/// Documentation for a constant
pub const THINGY: u32 = 42;
/// Documentation for a Rust `enum` (tagged union)
pub enum Whatsit {
/// Documentation for the `Yo` variant
Yo(Whatchamabob),
/// Documentation for the `HoHo` variant
HoHo,
}
/// Documentation for a data structure
pub struct Whatchamabob {
/// Doodads do dad
pub doodad: f64,
/// Whether or not this is a thingamabob
pub thingamabob: bool
}
/// Documentation for a trait (interface)
pub trait Frobnify {
/// `Frobnify` something
fn frob(&self);
}
/// Documentation specific to this struct's implementation of `Frobnify`
impl Frobnify for Whatchamabob {
/// `Frobnify` the `Whatchamabob`
fn frob(&self) {
println!("Frobbed: {}", self.doodad);
}
}
/// Documentation for a function
///
/// Pellentesque sodales lacus nisi, in malesuada lectus vestibulum eget.
/// Integer rhoncus imperdiet justo. Pellentesque egestas sem ac
/// consectetur suscipit. Maecenas tempus dignissim purus, eu tincidunt mi
/// tincidunt id. Morbi ac laoreet erat, eu ultricies neque. Fusce molestie
/// urna quis nisl condimentum, sit amet fringilla nunc ornare. Pellentesque
/// vestibulum ac nibh eu accumsan. In ornare orci at rhoncus finibus. Donec
/// sed ipsum ex. Pellentesque ante nisl, pharetra id purus auctor, euismod
/// semper erat. Nunc sit amet eros elit.
pub fn main() {
let foo = Whatchamabob{ doodad: 1.2, thingamabob: false };
foo.frob();
}

View file

@ -0,0 +1,121 @@
CREATE TABLESPACE myTs;
COMMENT ON TABLESPACE myTs IS 'Description of the tablespace.';
CREATE SCHEMA mySch;
COMMENT ON SCHEMA mySch IS 'Description of the schema.';
CREATE TYPE myType AS (col1 int) MODE DB2SQL;
COMMENT ON TYPE mytype IS 'Description of the type.';
CREATE TABLE myTab (
myCol1 INT NOT NULL,
myCol2 INT
);
COMMENT ON TABLE myTab IS 'Description of the table.';
COMMENT ON myTab (
myCol1 IS 'Description of the column.',
myCol2 IS 'Description of the column.'
);
ALTER TABLE myTab ADD CONSTRAINT myConst PRIMARY KEY (myCol1);
COMMENT ON CONSTRAINT myTab.myConst IS 'Description of the constraint.';
CREATE INDEX myInd ON
myTab (myCol2);
COMMENT ON INDEX myInd IS 'Description of the index.';
-- V11.1
CREATE USAGE LIST myUsList FOR TABLE myTab;
COMMENT ON USAGE LISTmyUsList IS 'Description of the usage list.';
/**
* Detailed description of the trigger.
*/
CREATE TRIGGER myTrig
AFTER INSERT ON myTab
REFERENCING NEW AS N
FOR EACH ROW
BEGIN
END;
COMMENT ON TRIGGER myTrig IS 'General description of the trigger.';
CREATE VARIABLE myVar INT;
COMMENT ON VARIABLE myVar IS 'General description of the variable.';
/**
* General description of the function (reads until the first dot).
* Detailed description of the function, until the first empty line.
*
* IN VAR1
* Description of IN parameter in variable VAR1.
* OUT VAR2
* Description of OUT parameter in variable VAR2.
* INOUT VAR3
* Description of INOUT parameter in variable VAR3.
* RETURNS Description of what it returns.
*/
CREATE FUNCTION myfun (
IN VAR1 INT,
OUT VAR2 INT,
INOUT VAR3 INT)
RETURNS INT
BEGIN
END;
/**
* General description of the procedure (reads until the first dot).
* Detailed description of the procedure, until the first empty line.
*
* IN VAR1
* Description of IN parameter in variable VAR1.
* OUT VAR2
* Description of OUT parameter in variable VAR2.
* INOUT VAR3
* Description of INOUT parameter in variable VAR3.
*/
CREATE PROCEDURE myProc (
IN VAR1 INT,
OUT VAR2 INT,
INOUT VAR3 INT)
BEGIN
END;
CREATE MODULE myMod;
COMMENT ON MODULE myMod IS 'General description of the module.';
/**
* General description of the procedure (reads until the first dot).
* Detailed description of the procedure, until the first empty line.
*
* IN VAR1
* Description of IN parameter in variable VAR1.
* OUT VAR2
* Description of OUT parameter in variable VAR2.
* INOUT VAR3
* Description of INOUT parameter in variable VAR3.
*/
ALTER MODULE myMod
ADD PROCEDURE myProc (
IN VAR1 INT,
OUT VAR2 INT,
INOUT VAR3 INT)
BEGIN
END;
CREATE ROLE myRole;
COMMENT ON ROLE myRole IS 'Description of the role.';
CREATE SEQUENCE mySeq;
COMMENT ON ROLE mySeq IS 'Description of the sequence.';

View file

@ -0,0 +1,22 @@
/**
* This is a class documentation comment. This text shows at the top of the page for this class
*
* @author Joe Schmoe
*/
class Doc {
/**
* This is a field comment for a variable
*/
private val field = 0
/**
* This is a method comment. It has parameter tags (param) and a return value tag (return).
*
* @param num a number with the variable name "num"
* @return another number
*/
def method(num: Long): Int = {
//...code here
???
}
}

View file

@ -0,0 +1 @@
FooClass comment: 'This is a comment ....'.

View file

@ -0,0 +1,3 @@
prog def hello
di "Hello, World!"
end

View file

@ -0,0 +1,9 @@
/**
Adds two numbers
:param: a an integer.
:param: b another integer.
:returns: the sum of a and b
*/
func add(a: Int, b: Int) -> Int {
return a + b
}

View file

@ -0,0 +1,18 @@
#****f* RosettaCode/TclDocDemo
# FUNCTION
# TclDocDemo is a simple illustration of how to do documentation
# of Tcl code using Robodoc.
# SYNOPSYS
# TclDocDemo foo bar
# INPUTS
# foo -- the first part of the message to print
# bar -- the last part of the message to print
# RESULT
# No result
# NOTES
# Prints a message based on a template by filling in with the
# supplied strings.
#*****
proc TclDocDemo {foo bar} {
puts [format "%s -- %s" $foo $bar]
}

View file

@ -0,0 +1 @@
XYZ

View file

@ -0,0 +1,27 @@
// The meaning of life!
var mol = 42
// A function to add two numbers
var add = Fn.new { |x, y| x + y }
/* A class with some string utilites */
class StrUtil {
// reverses an ASCII string
static reverse(s) { s[-1..0] }
// capitalizes the first letter of an ASCII string
static capitalize(s) {
var firstByte = s[0].bytes[0]
if (firstByte >= 97 && firstByte <= 122) {
firstByte = firstByte - 32
return String.fromByte(firstByte) + s[1..-1]
}
return s
}
}
// test code
var smol = "meaning of life"
System.print("'%(smol)' + 123 = %(add.call(mol, 123))")
System.print("'%(smol)' reversed = %(StrUtil.reverse(smol))")
System.print("'%(smol)' capitalized = %(StrUtil.capitalize(smol))")

View file

@ -0,0 +1,2 @@
10 LET a=10: REM a is the number of apples
1000 DEF FN s(q)=q*q: REM s is a function that takes a single numeric parameter and returns its square

View file

@ -0,0 +1,7 @@
10 GOSUB 2000: REM call a subroutine to print the documentation
1999 STOP
2000 REM Print the documentation
2010 LPRINT "a is the number of apples"
2020 LPRINT "s is a function that takes a single numeric parameter and returns"
2030 LPRINT "its square"
2040 RETURN