doc: Fix formatting in code blocks

This commit is contained in:
Rémi Verschelde 2018-12-14 09:37:19 +01:00
parent fc2038e128
commit e588c24168
10 changed files with 67 additions and 81 deletions

View File

@ -127,7 +127,7 @@
<description> <description>
Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant. Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
[codeblock] [codeblock]
a = atan(0,-1) # a is 3.141593 a = atan(0, -1) # a is 3.141593
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -175,7 +175,7 @@
# a is 'A' # a is 'A'
a = char(65) a = char(65)
# a is 'a' # a is 'a'
a = char(65+32) a = char(65 + 32)
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -230,7 +230,7 @@
Returns the cosine of angle [code]s[/code] in radians. Returns the cosine of angle [code]s[/code] in radians.
[codeblock] [codeblock]
# prints 1 and -1 # prints 1 and -1
print(cos(PI*2)) print(cos(PI * 2))
print(cos(PI)) print(cos(PI))
[/codeblock] [/codeblock]
</description> </description>
@ -584,7 +584,7 @@
<description> <description>
Returns the maximum of two values. Returns the maximum of two values.
[codeblock] [codeblock]
max(1,2) # returns 2 max(1, 2) # returns 2
max(-3.99, -4) # returns -3.99 max(-3.99, -4) # returns -3.99
[/codeblock] [/codeblock]
</description> </description>
@ -599,7 +599,7 @@
<description> <description>
Returns the minimum of two values. Returns the minimum of two values.
[codeblock] [codeblock]
min(1,2) # returns 1 min(1, 2) # returns 1
min(-3.99, -4) # returns -4 min(-3.99, -4) # returns -4
[/codeblock] [/codeblock]
</description> </description>
@ -657,7 +657,7 @@
<description> <description>
Returns the result of [code]x[/code] raised to the power of [code]y[/code]. Returns the result of [code]x[/code] raised to the power of [code]y[/code].
[codeblock] [codeblock]
pow(2,5) # returns 32 pow(2, 5) # returns 32
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -681,8 +681,8 @@
<description> <description>
Converts one or more arguments to strings in the best way possible and prints them to the console. Converts one or more arguments to strings in the best way possible and prints them to the console.
[codeblock] [codeblock]
a = [1,2,3] a = [1, 2, 3]
print("a","b",a) # prints ab[1, 2, 3] print("a", "b", a) # prints ab[1, 2, 3]
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -1009,7 +1009,7 @@
<description> <description>
Returns the tangent of angle [code]s[/code] in radians. Returns the tangent of angle [code]s[/code] in radians.
[codeblock] [codeblock]
tan( deg2rad(45) ) # returns 1 tan(deg2rad(45)) # returns 1
[/codeblock] [/codeblock]
</description> </description>
</method> </method>

View File

@ -47,8 +47,7 @@
Adds a new point at the given position with the given identifier. The algorithm prefers points with lower [code]weight_scale[/code] to form a path. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger. Adds a new point at the given position with the given identifier. The algorithm prefers points with lower [code]weight_scale[/code] to form a path. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger.
[codeblock] [codeblock]
var as = AStar.new() var as = AStar.new()
as.add_point(1, Vector3(1, 0, 0), 4) # Adds the point (1, 0, 0) with weight_scale 4 and id 1
as.add_point(1, Vector3(1,0,0), 4) # Adds the point (1,0,0) with weight_scale=4 and id=1
[/codeblock] [/codeblock]
If there already exists a point for the given id, its position and weight scale are updated to the given values. If there already exists a point for the given id, its position and weight scale are updated to the given values.
</description> </description>
@ -81,15 +80,12 @@
<argument index="2" name="bidirectional" type="bool" default="true"> <argument index="2" name="bidirectional" type="bool" default="true">
</argument> </argument>
<description> <description>
Creates a segment between the given points. Creates a segment between the given points. If [code]bidirectional[/code] is [code]false[/code], only movement from [code]id[/code] to [code]to_id[/code] is allowed, not the reverse direction.
[codeblock] [codeblock]
var as = AStar.new() var as = AStar.new()
as.add_point(1, Vector3(1, 1, 0))
as.add_point(1, Vector3(1,1,0)) as.add_point(2, Vector3(0, 5, 0))
as.add_point(2, Vector3(0,5,0)) as.connect_points(1, 2, false)
as.connect_points(1, 2, false) # If bidirectional=false it's only possible to go from point 1 to point 2
# and not from point 2 to point 1.
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -129,15 +125,12 @@
Returns the closest position to [code]to_position[/code] that resides inside a segment between two connected points. Returns the closest position to [code]to_position[/code] that resides inside a segment between two connected points.
[codeblock] [codeblock]
var as = AStar.new() var as = AStar.new()
as.add_point(1, Vector3(0, 0, 0))
as.add_point(1, Vector3(0,0,0)) as.add_point(2, Vector3(0, 5, 0))
as.add_point(2, Vector3(0,5,0))
as.connect_points(1, 2) as.connect_points(1, 2)
var res = as.get_closest_position_in_segment(Vector3(3, 3, 0)) # returns (0, 3, 0)
var res = as.get_closest_position_in_segment(Vector3(3,3,0)) # returns (0, 3, 0)
[/codeblock] [/codeblock]
The result is in the segment that goes from [code]y=0[/code] to [code]y=5[/code]. It's the closest position in the segment to the given point. The result is in the segment that goes from [code]y = 0[/code] to [code]y = 5[/code]. It's the closest position in the segment to the given point.
</description> </description>
</method> </method>
<method name="get_id_path"> <method name="get_id_path">
@ -151,11 +144,10 @@
Returns an array with the ids of the points that form the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path. Returns an array with the ids of the points that form the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path.
[codeblock] [codeblock]
var as = AStar.new() var as = AStar.new()
as.add_point(1, Vector3(0, 0, 0))
as.add_point(1, Vector3(0,0,0)) as.add_point(2, Vector3(0, 1, 0), 1) # default weight is 1
as.add_point(2, Vector3(0,1,0), 1) # default weight is 1 as.add_point(3, Vector3(1, 1, 0))
as.add_point(3, Vector3(1,1,0)) as.add_point(4, Vector3(2, 0, 0))
as.add_point(4, Vector3(2,0,0))
as.connect_points(1, 2, false) as.connect_points(1, 2, false)
as.connect_points(2, 3, false) as.connect_points(2, 3, false)
@ -177,11 +169,10 @@
Returns an array with the ids of the points that form the connect with the given point. Returns an array with the ids of the points that form the connect with the given point.
[codeblock] [codeblock]
var as = AStar.new() var as = AStar.new()
as.add_point(1, Vector3(0, 0, 0))
as.add_point(1, Vector3(0,0,0)) as.add_point(2, Vector3(0, 1, 0))
as.add_point(2, Vector3(0,1,0)) as.add_point(3, Vector3(1, 1, 0))
as.add_point(3, Vector3(1,1,0)) as.add_point(4, Vector3(2, 0, 0))
as.add_point(4, Vector3(2,0,0))
as.connect_points(1, 2, true) as.connect_points(1, 2, true)
as.connect_points(1, 3, true) as.connect_points(1, 3, true)

View File

@ -196,10 +196,10 @@
<description> <description>
Return true if the array contains given value. Return true if the array contains given value.
[codeblock] [codeblock]
[ "inside", 7 ].has("inside") == true ["inside", 7].has("inside") == true
[ "inside", 7 ].has("outside") == false ["inside", 7].has("outside") == false
[ "inside", 7 ].has(7) == true ["inside", 7].has(7) == true
[ "inside", 7 ].has("7") == false ["inside", 7].has("7") == false
[/codeblock] [/codeblock]
</description> </description>
</method> </method>

View File

@ -6,9 +6,9 @@
The [code]ArrayMesh[/code] is used to construct a [Mesh] by specifying the attributes as arrays. The most basic example is the creation of a single triangle The [code]ArrayMesh[/code] is used to construct a [Mesh] by specifying the attributes as arrays. The most basic example is the creation of a single triangle
[codeblock] [codeblock]
var vertices = PoolVector3Array() var vertices = PoolVector3Array()
vertices.push_back(Vector3(0,1,0)) vertices.push_back(Vector3(0, 1, 0))
vertices.push_back(Vector3(1,0,0)) vertices.push_back(Vector3(1, 0, 0))
vertices.push_back(Vector3(0,0,1)) vertices.push_back(Vector3(0, 0, 1))
# Initialize the ArrayMesh. # Initialize the ArrayMesh.
var arr_mesh = ArrayMesh.new() var arr_mesh = ArrayMesh.new()
var arrays = [] var arrays = []

View File

@ -19,11 +19,6 @@
</argument> </argument>
<description> <description>
Constructs a color from an HTML hexadecimal color string in ARGB or RGB format. See also [method @GDScript.ColorN]. Constructs a color from an HTML hexadecimal color string in ARGB or RGB format. See also [method @GDScript.ColorN].
The following string formats are supported:
[code]"#ff00ff00"[/code] - ARGB format with '#'
[code]"ff00ff00"[/code] - ARGB format
[code]"#ff00ff"[/code] - RGB format with '#'
[code]"ff00ff"[/code] - RGB format
[codeblock] [codeblock]
# Each of the following creates the same color RGBA(178, 217, 10, 255) # Each of the following creates the same color RGBA(178, 217, 10, 255)
var c1 = Color("#ffb2d90a") # ARGB format with '#' var c1 = Color("#ffb2d90a") # ARGB format with '#'
@ -57,7 +52,7 @@
<description> <description>
Constructs a color from an RGB profile using values between 0 and 1. Alpha will always be 1. Constructs a color from an RGB profile using values between 0 and 1. Alpha will always be 1.
[codeblock] [codeblock]
var c = Color(0.2, 1.0, .7) # Equivalent to RGBA(51, 255, 178, 255) var c = Color(0.2, 1.0, 0.7) # Equivalent to RGBA(51, 255, 178, 255)
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -75,7 +70,7 @@
<description> <description>
Constructs a color from an RGBA profile using values between 0 and 1. Constructs a color from an RGBA profile using values between 0 and 1.
[codeblock] [codeblock]
var c = Color(0.2, 1.0, .7, .8) # Equivalent to RGBA(51, 255, 178, 204) var c = Color(0.2, 1.0, 0.7, 0.8) # Equivalent to RGBA(51, 255, 178, 204)
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -88,8 +83,8 @@
Returns a new color resulting from blending this color over another. If the color is opaque, the result is also opaque. The second color may have a range of alpha values. Returns a new color resulting from blending this color over another. If the color is opaque, the result is also opaque. The second color may have a range of alpha values.
[codeblock] [codeblock]
var bg = Color(0.0, 1.0, 0.0, 0.5) # Green with alpha of 50% var bg = Color(0.0, 1.0, 0.0, 0.5) # Green with alpha of 50%
var fg = Color(1.0, 0.0, 0.0, .5) # Red with alpha of 50% var fg = Color(1.0, 0.0, 0.0, 0.5) # Red with alpha of 50%
var blendedColor = bg.blend(fg) # Brown with alpha of 75% var blended_color = bg.blend(fg) # Brown with alpha of 75%
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -99,8 +94,8 @@
<description> <description>
Returns the most contrasting color. Returns the most contrasting color.
[codeblock] [codeblock]
var c = Color(.3, .4, .9) var c = Color(0.3, 0.4, 0.9)
var contrastedColor = c.contrasted() # Equivalent to RGBA(204, 229, 102, 255) var contrasted_color = c.contrasted() # Equivalent to RGBA(204, 229, 102, 255)
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -110,7 +105,7 @@
<argument index="0" name="amount" type="float"> <argument index="0" name="amount" type="float">
</argument> </argument>
<description> <description>
Returns a new color resulting from making this color darker by the specified percentage (0-1). Returns a new color resulting from making this color darker by the specified percentage (ratio from 0 to 1).
[codeblock] [codeblock]
var green = Color(0.0, 1.0, 0.0) var green = Color(0.0, 1.0, 0.0)
var darkgreen = green.darkened(0.2) # 20% darker than regular green var darkgreen = green.darkened(0.2) # 20% darker than regular green
@ -140,7 +135,7 @@
</return> </return>
<description> <description>
Returns the color's grayscale representation. Returns the color's grayscale representation.
The gray is calculated by [code](r + g + b) / 3[/code]. The gray value is calculated as [code](r + g + b) / 3[/code].
[codeblock] [codeblock]
var c = Color(0.2, 0.45, 0.82) var c = Color(0.2, 0.45, 0.82)
var gray = c.gray() # a value of 0.466667 var gray = c.gray() # a value of 0.466667
@ -153,8 +148,8 @@
<description> <description>
Returns the inverted color [code](1 - r, 1 - g, 1 - b, 1 - a)[/code]. Returns the inverted color [code](1 - r, 1 - g, 1 - b, 1 - a)[/code].
[codeblock] [codeblock]
var c = Color(.3, .4, .9) var c = Color(0.3, 0.4, 0.9)
var invertedColor = c.inverted() # a color of an RGBA(178, 153, 26, 255) var inverted_color = c.inverted() # a color of an RGBA(178, 153, 26, 255)
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -164,7 +159,7 @@
<argument index="0" name="amount" type="float"> <argument index="0" name="amount" type="float">
</argument> </argument>
<description> <description>
Returns a new color resulting from making this color lighter by the specified percentage (0-1). Returns a new color resulting from making this color lighter by the specified percentage (ratio from 0 to 1).
[codeblock] [codeblock]
var green = Color(0.0, 1.0, 0.0) var green = Color(0.0, 1.0, 0.0)
var lightgreen = green.lightened(0.2) # 20% lighter than regular green var lightgreen = green.lightened(0.2) # 20% lighter than regular green
@ -179,7 +174,7 @@
<argument index="1" name="t" type="float"> <argument index="1" name="t" type="float">
</argument> </argument>
<description> <description>
Returns the linear interpolation with another color. The value t is between 0 and 1. Returns the linear interpolation with another color. The interpolation factor [code]t[/code] is between 0 and 1.
[codeblock] [codeblock]
var c1 = Color(1.0, 0.0, 0.0) var c1 = Color(1.0, 0.0, 0.0)
var c2 = Color(0.0, 1.0, 0.0) var c2 = Color(0.0, 1.0, 0.0)
@ -193,7 +188,7 @@
<description> <description>
Returns the color's 32-bit integer in ABGR format (each byte represents a component of the ABGR profile). ABGR is the reversed version of the default format. Returns the color's 32-bit integer in ABGR format (each byte represents a component of the ABGR profile). ABGR is the reversed version of the default format.
[codeblock] [codeblock]
var c = Color(1, .5, .2) var c = Color(1, 0.5, 0.2)
print(c.to_abgr32()) # Prints 4281565439 print(c.to_abgr32()) # Prints 4281565439
[/codeblock] [/codeblock]
</description> </description>
@ -204,7 +199,7 @@
<description> <description>
Returns the color's 64-bit integer in ABGR format (each word represents a component of the ABGR profile). ABGR is the reversed version of the default format. Returns the color's 64-bit integer in ABGR format (each word represents a component of the ABGR profile). ABGR is the reversed version of the default format.
[codeblock] [codeblock]
var c = Color(1, .5, .2) var c = Color(1, 0.5, 0.2)
print(c.to_abgr64()) # Prints -225178692812801 print(c.to_abgr64()) # Prints -225178692812801
[/codeblock] [/codeblock]
</description> </description>
@ -215,7 +210,7 @@
<description> <description>
Returns the color's 32-bit integer in ARGB format (each byte represents a component of the ARGB profile). ARGB is more compatible with DirectX. Returns the color's 32-bit integer in ARGB format (each byte represents a component of the ARGB profile). ARGB is more compatible with DirectX.
[codeblock] [codeblock]
var c = Color(1, .5, .2) var c = Color(1, 0.5, 0.2)
print(c.to_argb32()) # Prints 4294934323 print(c.to_argb32()) # Prints 4294934323
[/codeblock] [/codeblock]
</description> </description>
@ -226,7 +221,7 @@
<description> <description>
Returns the color's 64-bit integer in ARGB format (each word represents a component of the ARGB profile). ARGB is more compatible with DirectX. Returns the color's 64-bit integer in ARGB format (each word represents a component of the ARGB profile). ARGB is more compatible with DirectX.
[codeblock] [codeblock]
var c = Color(1, .5, .2) var c = Color(1, 0.5, 0.2)
print(c.to_argb64()) # Prints -2147470541 print(c.to_argb64()) # Prints -2147470541
[/codeblock] [/codeblock]
</description> </description>
@ -240,7 +235,7 @@
Returns the color's HTML hexadecimal color string in ARGB format (ex: [code]ff34f822[/code]). Returns the color's HTML hexadecimal color string in ARGB format (ex: [code]ff34f822[/code]).
Setting [code]with_alpha[/code] to [code]false[/code] excludes alpha from the hexadecimal string. Setting [code]with_alpha[/code] to [code]false[/code] excludes alpha from the hexadecimal string.
[codeblock] [codeblock]
var c = Color(1, 1, 1, .5) var c = Color(1, 1, 1, 0.5)
var s1 = c.to_html() # Results "7fffffff" var s1 = c.to_html() # Results "7fffffff"
var s2 = c.to_html(false) # Results 'ffffff' var s2 = c.to_html(false) # Results 'ffffff'
[/codeblock] [/codeblock]
@ -252,7 +247,7 @@
<description> <description>
Returns the color's 32-bit integer in RGBA format (each byte represents a component of the RGBA profile). RGBA is Godot's default format. Returns the color's 32-bit integer in RGBA format (each byte represents a component of the RGBA profile). RGBA is Godot's default format.
[codeblock] [codeblock]
var c = Color(1, .5, .2) var c = Color(1, 0.5, 0.2)
print(c.to_rgba32()) # Prints 4286526463 print(c.to_rgba32()) # Prints 4286526463
[/codeblock] [/codeblock]
</description> </description>
@ -263,7 +258,7 @@
<description> <description>
Returns the color's 64-bit integer in RGBA format (each word represents a component of the RGBA profile). RGBA is Godot's default format. Returns the color's 64-bit integer in RGBA format (each word represents a component of the RGBA profile). RGBA is Godot's default format.
[codeblock] [codeblock]
var c = Color(1, .5, .2) var c = Color(1, 0.5, 0.2)
print(c.to_rgba64()) # Prints -140736629309441 print(c.to_rgba64()) # Prints -140736629309441
[/codeblock] [/codeblock]
</description> </description>

View File

@ -35,7 +35,7 @@
func get_import_options(i): func get_import_options(i):
return [{"name": "my_option", "default_value": false}] return [{"name": "my_option", "default_value": false}]
func import(source_file, save_path, options, r_platform_variants, r_gen_files): func import(source_file, save_path, options, platform_variants, gen_files):
var file = File.new() var file = File.new()
if file.open(source_file, File.READ) != OK: if file.open(source_file, File.READ) != OK:
return FAILED return FAILED

View File

@ -20,7 +20,7 @@
func iterate(node): func iterate(node):
if node != null: if node != null:
node.name = "modified_"+node.name node.name = "modified_" + node.name
for child in node.get_children(): for child in node.get_children():
iterate(child) iterate(child)
[/codeblock] [/codeblock]

View File

@ -108,14 +108,14 @@
Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.: Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.:
[codeblock] [codeblock]
var fields = {"username": "user", "password": "pass"} var fields = {"username": "user", "password": "pass"}
String queryString = httpClient.query_string_from_dict(fields) String query_string = http_client.query_string_from_dict(fields)
returns:= "username=user&amp;password=pass" # returns: "username=user&amp;password=pass"
[/codeblock] [/codeblock]
Furthermore, if a key has a null value, only the key itself is added, without equal sign and value. If the value is an array, for each value in it a pair with the same key is added. Furthermore, if a key has a null value, only the key itself is added, without equal sign and value. If the value is an array, for each value in it a pair with the same key is added.
[codeblock] [codeblock]
var fields = {"single": 123, "not_valued": null, "multiple": [22, 33, 44]} var fields = {"single": 123, "not_valued": null, "multiple": [22, 33, 44]}
String queryString = httpClient.query_string_from_dict(fields) String query_string = http_client.query_string_from_dict(fields)
returns:= "single=123&amp;not_valued&amp;multiple=22&amp;multiple=33&amp;multiple=44" # returns: "single=123&amp;not_valued&amp;multiple=22&amp;multiple=33&amp;multiple=44"
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
@ -143,9 +143,9 @@
To create a POST request with query strings to push to the server, do: To create a POST request with query strings to push to the server, do:
[codeblock] [codeblock]
var fields = {"username" : "user", "password" : "pass"} var fields = {"username" : "user", "password" : "pass"}
var queryString = httpClient.query_string_from_dict(fields) var query_string = http_client.query_string_from_dict(fields)
var headers = ["Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(queryString.length())] var headers = ["Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(query_string.length())]
var result = httpClient.request(httpClient.METHOD_POST, "index.php", headers, queryString) var result = http_client.request(http_client.METHOD_POST, "index.php", headers, query_string)
[/codeblock] [/codeblock]
</description> </description>
</method> </method>

View File

@ -11,9 +11,9 @@
var mdt = MeshDataTool.new() var mdt = MeshDataTool.new()
mdt.create_from_surface(mesh, 0) mdt.create_from_surface(mesh, 0)
for i in range(mdt.get_vertex_count()): for i in range(mdt.get_vertex_count()):
var vertex = mdt.get_vertex(i) var vertex = mdt.get_vertex(i)
... ...
mdt.set_vertex(i, vertex) mdt.set_vertex(i, vertex)
mesh.surface_remove(0) mesh.surface_remove(0)
mdt.commit_to_surface(mesh) mdt.commit_to_surface(mesh)
[/codeblock] [/codeblock]

View File

@ -7,9 +7,9 @@
The ScriptCreateDialog creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling a [method popup]() method. The ScriptCreateDialog creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling a [method popup]() method.
[codeblock] [codeblock]
func _ready(): func _ready():
dialog.config("Node", "res://new_node.gd") # for in-engine types dialog.config("Node", "res://new_node.gd") # for in-engine types
dialog.config("\"res://base_node.gd\"", "res://derived_node.gd") # for script types dialog.config("\"res://base_node.gd\"", "res://derived_node.gd") # for script types
dialog.popup_centered() dialog.popup_centered()
[/codeblock] [/codeblock]
</description> </description>
<tutorials> <tutorials>