mirror of
https://github.com/boostorg/build.git
synced 2026-02-18 01:52:17 +00:00
print.jam; support use of "::" as prefix in paragraphs/blocks to output preformatted text.
class.jam; add use of "::" for code samples. [SVN r16019]
This commit is contained in:
@@ -9,26 +9,26 @@
|
||||
# the "constructor", which in turn sets instance attributes and
|
||||
# defines rules:
|
||||
#
|
||||
# rule myclass ( arg1 ) # constructor
|
||||
# {
|
||||
# self.attribute = $(arg1) ;
|
||||
#
|
||||
# rule method1 ( ) # method
|
||||
# {
|
||||
# return [ method2 ] ;
|
||||
# }
|
||||
#
|
||||
# rule method2 ( ) # method
|
||||
# {
|
||||
# return $(self.attribute) ;
|
||||
# }
|
||||
# }
|
||||
# class myclass ; # establish myclass as a class
|
||||
#:: rule myclass ( arg1 ) # constructor
|
||||
#:: {
|
||||
#:: self.attribute = $(arg1) ;
|
||||
#::
|
||||
#:: rule method1 ( ) # method
|
||||
#:: {
|
||||
#:: return [ method2 ] ;
|
||||
#:: }
|
||||
#::
|
||||
#:: rule method2 ( ) # method
|
||||
#:: {
|
||||
#:: return $(self.attribute) ;
|
||||
#:: }
|
||||
#:: }
|
||||
#:: class myclass ; # establish myclass as a class
|
||||
#
|
||||
# New instance modules are created by invoking [ new <class> <args...> ]:
|
||||
#
|
||||
# local x = [ new myclass foo ] ; # x is a new myclass object
|
||||
# assert.result foo : [ $(x).method1 ] ; # $(x).method1 returns "foo"
|
||||
#:: local x = [ new myclass foo ] ; # x is a new myclass object
|
||||
#:: assert.result foo : [ $(x).method1 ] ; # $(x).method1 returns "foo"
|
||||
#
|
||||
# To write a derived class, you must:
|
||||
#
|
||||
@@ -37,21 +37,21 @@
|
||||
#
|
||||
# 2. add the base classes to the derived class declaration.
|
||||
#
|
||||
# rule derived ( arg )
|
||||
# {
|
||||
# myclass.__init__ $(arg) ; # call base __init__
|
||||
# rule method2 ( ) # method override
|
||||
# {
|
||||
# return $(self.attribute)XXX ;
|
||||
# }
|
||||
# }
|
||||
# class derived : myclass ;
|
||||
#:: rule derived ( arg )
|
||||
#:: {
|
||||
#:: myclass.__init__ $(arg) ; # call base __init__
|
||||
#:: rule method2 ( ) # method override
|
||||
#:: {
|
||||
#:: return $(self.attribute)XXX ;
|
||||
#:: }
|
||||
#:: }
|
||||
#:: class derived : myclass ;
|
||||
#
|
||||
# All methods operate virtually, replacing behavior in the base
|
||||
# classes. For example:
|
||||
#
|
||||
# local y = [ new derived foo ] ; # y is a new derived object
|
||||
# assert.result fooXXX : [ $(y).method1 ] ; # $(y).method1 returns "foo"
|
||||
#:: local y = [ new derived foo ] ; # y is a new derived object
|
||||
#:: assert.result fooXXX : [ $(y).method1 ] ; # $(y).method1 returns "foo"
|
||||
#
|
||||
# Each class instance is its own core Jam module. All instance
|
||||
# attributes and methods are accessible without additional
|
||||
|
||||
@@ -52,7 +52,14 @@ rule section (
|
||||
local paragraph = ;
|
||||
while $(description) && $(description[1]) = "" { description = $(description[2-]) ; }
|
||||
while $(description) && $(description[1]) != "" { paragraph += $(description[1]) ; description = $(description[2-]) ; }
|
||||
lines [ split-at-words " " $(paragraph) ] : " " ;
|
||||
if [ MATCH "^(::).*" : $(paragraph) ]
|
||||
{
|
||||
lines [ MATCH "^::(.*)" : $(paragraph) ] : " " " " ;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines [ split-at-words " " $(paragraph) ] : " " ;
|
||||
}
|
||||
lines ;
|
||||
}
|
||||
}
|
||||
@@ -151,13 +158,15 @@ rule split-at-words (
|
||||
rule lines (
|
||||
text * # The lines of text.
|
||||
: indent ? # Optional indentation prepended to each line after the first one.
|
||||
outdent ? # Optional indentation to prepend to the first line.
|
||||
)
|
||||
{
|
||||
text ?= "" ;
|
||||
indent ?= "" ;
|
||||
outdent ?= "" ;
|
||||
if $(output-type) = plain
|
||||
{
|
||||
text $(text[1]) $(indent)$(text[2-]) ;
|
||||
text $(outdent)$(text[1]) $(indent)$(text[2-]) ;
|
||||
}
|
||||
else if $(output-type) = html
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user