Skip to content

Commit 7ae7575

Browse files
committed
Begin documenting std and add doc generation using naturaldocs
Naturaldocs isn't really that great but it seems easier to get something working than with doxygen, for which we would need to convert rust code to something C++ish. We probably want to just write a rustdoc utility at some point.
1 parent 013107a commit 7ae7575

23 files changed

+1412
-110
lines changed

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ rm -f config.mk.bak
387387

388388
step_msg "making directories"
389389
for i in \
390-
doc \
390+
doc doc/std \
391+
nd nd/std \
391392
rt rt/isaac rt/bigint rt/sync rt/test rt/arch/i386 \
392393
rt/libuv rt/libuv/src/ares rt/libuv/src/eio rt/libuv/src/ev \
393394
rustllvm dl \

doc/Languages.txt

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
Format: 1.51
2+
3+
# This is the Natural Docs languages file for this project. If you change
4+
# anything here, it will apply to THIS PROJECT ONLY. If you'd like to change
5+
# something for all your projects, edit the Languages.txt in Natural Docs'
6+
# Config directory instead.
7+
8+
9+
# You can prevent certain file extensions from being scanned like this:
10+
# Ignore Extensions: [extension] [extension] ...
11+
12+
13+
#-------------------------------------------------------------------------------
14+
# SYNTAX:
15+
#
16+
# Unlike other Natural Docs configuration files, in this file all comments
17+
# MUST be alone on a line. Some languages deal with the # character, so you
18+
# cannot put comments on the same line as content.
19+
#
20+
# Also, all lists are separated with spaces, not commas, again because some
21+
# languages may need to use them.
22+
#
23+
# Language: [name]
24+
# Alter Language: [name]
25+
# Defines a new language or alters an existing one. Its name can use any
26+
# characters. If any of the properties below have an add/replace form, you
27+
# must use that when using Alter Language.
28+
#
29+
# The language Shebang Script is special. It's entry is only used for
30+
# extensions, and files with those extensions have their shebang (#!) lines
31+
# read to determine the real language of the file. Extensionless files are
32+
# always treated this way.
33+
#
34+
# The language Text File is also special. It's treated as one big comment
35+
# so you can put Natural Docs content in them without special symbols. Also,
36+
# if you don't specify a package separator, ignored prefixes, or enum value
37+
# behavior, it will copy those settings from the language that is used most
38+
# in the source tree.
39+
#
40+
# Extensions: [extension] [extension] ...
41+
# [Add/Replace] Extensions: [extension] [extension] ...
42+
# Defines the file extensions of the language's source files. You can
43+
# redefine extensions found in the main languages file. You can use * to
44+
# mean any undefined extension.
45+
#
46+
# Shebang Strings: [string] [string] ...
47+
# [Add/Replace] Shebang Strings: [string] [string] ...
48+
# Defines a list of strings that can appear in the shebang (#!) line to
49+
# designate that it's part of the language. You can redefine strings found
50+
# in the main languages file.
51+
#
52+
# Ignore Prefixes in Index: [prefix] [prefix] ...
53+
# [Add/Replace] Ignored Prefixes in Index: [prefix] [prefix] ...
54+
#
55+
# Ignore [Topic Type] Prefixes in Index: [prefix] [prefix] ...
56+
# [Add/Replace] Ignored [Topic Type] Prefixes in Index: [prefix] [prefix] ...
57+
# Specifies prefixes that should be ignored when sorting symbols in an
58+
# index. Can be specified in general or for a specific topic type.
59+
#
60+
#------------------------------------------------------------------------------
61+
# For basic language support only:
62+
#
63+
# Line Comments: [symbol] [symbol] ...
64+
# Defines a space-separated list of symbols that are used for line comments,
65+
# if any.
66+
#
67+
# Block Comments: [opening sym] [closing sym] [opening sym] [closing sym] ...
68+
# Defines a space-separated list of symbol pairs that are used for block
69+
# comments, if any.
70+
#
71+
# Package Separator: [symbol]
72+
# Defines the default package separator symbol. The default is a dot.
73+
#
74+
# [Topic Type] Prototype Enders: [symbol] [symbol] ...
75+
# When defined, Natural Docs will attempt to get a prototype from the code
76+
# immediately following the topic type. It stops when it reaches one of
77+
# these symbols. Use \n for line breaks.
78+
#
79+
# Line Extender: [symbol]
80+
# Defines the symbol that allows a prototype to span multiple lines if
81+
# normally a line break would end it.
82+
#
83+
# Enum Values: [global|under type|under parent]
84+
# Defines how enum values are referenced. The default is global.
85+
# global - Values are always global, referenced as 'value'.
86+
# under type - Values are under the enum type, referenced as
87+
# 'package.enum.value'.
88+
# under parent - Values are under the enum's parent, referenced as
89+
# 'package.value'.
90+
#
91+
# Perl Package: [perl package]
92+
# Specifies the Perl package used to fine-tune the language behavior in ways
93+
# too complex to do in this file.
94+
#
95+
#------------------------------------------------------------------------------
96+
# For full language support only:
97+
#
98+
# Full Language Support: [perl package]
99+
# Specifies the Perl package that has the parsing routines necessary for full
100+
# language support.
101+
#
102+
#-------------------------------------------------------------------------------
103+
104+
# The following languages are defined in the main file, if you'd like to alter
105+
# them:
106+
#
107+
# Text File, Shebang Script, C/C++, C#, Java, JavaScript, Perl, Python,
108+
# PHP, SQL, Visual Basic, Pascal, Assembly, Ada, Tcl, Ruby, Makefile,
109+
# ActionScript, ColdFusion, R, Fortran
110+
111+
# If you add a language that you think would be useful to other developers
112+
# and should be included in Natural Docs by default, please e-mail it to
113+
# languages [at] naturaldocs [dot] org.
114+
115+
116+
Language: Rust
117+
118+
Extensions: rc rs
119+
Line Comment: //
120+
Block Comment: /* */
121+
Package Separator: ::
122+
Function Prototype Enders: ; {
123+
Type Prototype Enders: ; }
124+
Class Prototype Enders: {

doc/Topics.txt

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
Format: 1.51
2+
3+
# This is the Natural Docs topics file for this project. If you change anything
4+
# here, it will apply to THIS PROJECT ONLY. If you'd like to change something
5+
# for all your projects, edit the Topics.txt in Natural Docs' Config directory
6+
# instead.
7+
8+
9+
# If you'd like to prevent keywords from being recognized by Natural Docs, you
10+
# can do it like this:
11+
# Ignore Keywords: [keyword], [keyword], ...
12+
#
13+
# Or you can use the list syntax like how they are defined:
14+
# Ignore Keywords:
15+
# [keyword]
16+
# [keyword], [plural keyword]
17+
# ...
18+
19+
20+
#-------------------------------------------------------------------------------
21+
# SYNTAX:
22+
#
23+
# Topic Type: [name]
24+
# Alter Topic Type: [name]
25+
# Creates a new topic type or alters one from the main file. Each type gets
26+
# its own index and behavior settings. Its name can have letters, numbers,
27+
# spaces, and these charaters: - / . '
28+
#
29+
# Plural: [name]
30+
# Sets the plural name of the topic type, if different.
31+
#
32+
# Keywords:
33+
# [keyword]
34+
# [keyword], [plural keyword]
35+
# ...
36+
# Defines or adds to the list of keywords for the topic type. They may only
37+
# contain letters, numbers, and spaces and are not case sensitive. Plural
38+
# keywords are used for list topics. You can redefine keywords found in the
39+
# main topics file.
40+
#
41+
# Index: [yes|no]
42+
# Whether the topics get their own index. Defaults to yes. Everything is
43+
# included in the general index regardless of this setting.
44+
#
45+
# Scope: [normal|start|end|always global]
46+
# How the topics affects scope. Defaults to normal.
47+
# normal - Topics stay within the current scope.
48+
# start - Topics start a new scope for all the topics beneath it,
49+
# like class topics.
50+
# end - Topics reset the scope back to global for all the topics
51+
# beneath it.
52+
# always global - Topics are defined as global, but do not change the scope
53+
# for any other topics.
54+
#
55+
# Class Hierarchy: [yes|no]
56+
# Whether the topics are part of the class hierarchy. Defaults to no.
57+
#
58+
# Page Title If First: [yes|no]
59+
# Whether the topic's title becomes the page title if it's the first one in
60+
# a file. Defaults to no.
61+
#
62+
# Break Lists: [yes|no]
63+
# Whether list topics should be broken into individual topics in the output.
64+
# Defaults to no.
65+
#
66+
# Can Group With: [type], [type], ...
67+
# Defines a list of topic types that this one can possibly be grouped with.
68+
# Defaults to none.
69+
#-------------------------------------------------------------------------------
70+
71+
# The following topics are defined in the main file, if you'd like to alter
72+
# their behavior or add keywords:
73+
#
74+
# Generic, Class, Interface, Section, File, Group, Function, Variable,
75+
# Property, Type, Constant, Enumeration, Event, Delegate, Macro,
76+
# Database, Database Table, Database View, Database Index, Database
77+
# Cursor, Database Trigger, Cookie, Build Target
78+
79+
# If you add something that you think would be useful to other developers
80+
# and should be included in Natural Docs by default, please e-mail it to
81+
# topics [at] naturaldocs [dot] org.
82+
83+
84+
#Topic Type: Crate
85+
86+
# Plural: Crates
87+
# Scope: Always Global
88+
89+
# Keywords:
90+
# crate, crates
91+
92+
Topic Type: Syntax Extension
93+
94+
Plural: Syntax Extensions
95+
Scope: Always Global
96+
97+
Keywords:
98+
syntax extension, syntax extensions
99+
100+
#Alter Topic Type: Class
101+
102+
# Keywords:
103+
# object, objects
104+
# tag, tags
105+
# resource, resources
106+
107+
Topic Type: Module
108+
Plural: Modules
109+
Scope: Start
110+
Class Hierarchy: Yes
111+
Page Title If First: Yes
112+
113+
Keywords:
114+
module, modules
115+
116+
Topic Type: Object
117+
Plural: Objects
118+
Scope: Start
119+
Class Hierarchy: Yes
120+
121+
Keywords:
122+
obj, objs
123+
124+
Topic Type: Tag
125+
Plural: Tags
126+
Scope: Start
127+
Class Hierarchy: Yes
128+
129+
Keywords:
130+
tag, tags
131+
132+
#Alter Topic Type: Function
133+
134+
# Scope: Start
135+
# predicate, predicates
136+
137+
# Ignore Keywords:
138+
# method, methods
139+
# Keywords:
140+
# variant, variants
141+
142+
Topic Type: Variant
143+
144+
Plural: Variants
145+
Keywords:
146+
variant, variants
147+
148+
#Alter Topic Type: Type
149+
150+
# Keywords:
151+
# tag, tags
152+
153+
Topic Type: Predicate
154+
155+
Plural: Predicates
156+
Break Lists: Yes
157+
158+
Keywords:
159+
predicate, predicates

mk/docs.mk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ doc/%.html: %.texi doc/version.texi
1919
docsnap: doc/rust.pdf
2020
@$(call E, snap: doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf)
2121
$(Q)mv $< doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf
22+
23+
doc/std/index.html: nd/std/Languages.txt nd/std/Topics.txt \
24+
$(STDLIB_CRATE) $(STDLIB_INPUTS)
25+
@$(call E, naturaldocs: $@)
26+
naturaldocs -i $(S)src/lib -o HTML doc/std -p nd/std -r
27+
28+
nd/std/Languages.txt: $(S)doc/Languages.txt
29+
@$(call E, cp: $@)
30+
$(Q)cp $< $@
31+
32+
nd/std/Topics.txt: $(S)doc/Topics.txt
33+
@$(call E, cp: $@)
34+
$(Q)cp $< $@

src/lib/bitv.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
Module: bitv
3+
4+
Bitvectors.
5+
*/
16

27
export t;
38
export create;
@@ -23,12 +28,26 @@ export eq_vec;
2328
// an optimizing version of this module that produces a different obj
2429
// for the case where nbits <= 32.
2530

31+
/*
32+
Type: t
33+
34+
The bitvector type.
35+
*/
2636
type t = @{storage: [mutable uint], nbits: uint};
2737

2838

2939
// FIXME: this should be a constant once they work
3040
fn uint_bits() -> uint { ret 32u + (1u << 32u >> 27u); }
3141

42+
/*
43+
Function: create
44+
45+
Constructs a bitvector.
46+
47+
Parameters:
48+
nbits - The number of bits in the bitvector
49+
init - If true then the bits are initialized to 1, otherwise 0
50+
*/
3251
fn create(nbits: uint, init: bool) -> t {
3352
let elt = if init { !0u } else { 0u };
3453
let storage = vec::init_elt_mut::<uint>(elt, nbits / uint_bits() + 1u);

src/lib/box.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
/*
2+
Module: box
3+
*/
4+
15

26
export ptr_eq;
37

8+
/*
9+
Function: ptr_eq
10+
11+
Determine if two shared boxes point to the same object
12+
*/
413
fn ptr_eq<T>(a: @T, b: @T) -> bool {
514
let a_ptr: uint = unsafe::reinterpret_cast(a);
615
let b_ptr: uint = unsafe::reinterpret_cast(b);

src/lib/char.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
Module: char
3+
4+
Utilities for manipulating the char type
5+
*/
6+
7+
/*
8+
Function: is_whitespace
9+
10+
Indicates whether a character is whitespace.
11+
12+
Whitespace characters include space (U+0020), tab (U+0009), line feed
13+
(U+000A), carriage return (U+000D), and a number of less common
14+
ASCII and unicode characters.
15+
*/
116
pure fn is_whitespace(c: char) -> bool {
217
const ch_space: char = '\u0020';
318
const ch_ogham_space_mark: char = '\u1680';

0 commit comments

Comments
 (0)