Merge pull request #3749 from akien-mga/pr-codeblock
Implement support for [codeblock] tag in help
This commit is contained in:
commit
77fd9b1c57
3 changed files with 80 additions and 34 deletions
|
@ -9606,13 +9606,12 @@ This approximation makes straight segments between each point, then subdivides t
|
||||||
</class>
|
</class>
|
||||||
<class name="Directory" inherits="Reference" category="Core">
|
<class name="Directory" inherits="Reference" category="Core">
|
||||||
<brief_description>
|
<brief_description>
|
||||||
Directory type.
|
Type used to handle the filesystem.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
Directory type. Is used to manage directories and their content (not restricted to the project folder).
|
Directory type. Is used to manage directories and their content (not restricted to the project folder).
|
||||||
|
Example for how to iterate through the files of a directory:
|
||||||
How to iterate through the files of a directory example:
|
[codeblock]
|
||||||
|
|
||||||
func dir(path):
|
func dir(path):
|
||||||
var d = Directory.new()
|
var d = Directory.new()
|
||||||
if d.open( path )==0:
|
if d.open( path )==0:
|
||||||
|
@ -9620,12 +9619,13 @@ func dir(path):
|
||||||
var file_name = d.get_next()
|
var file_name = d.get_next()
|
||||||
while(file_name!=""):
|
while(file_name!=""):
|
||||||
if d.current_is_dir():
|
if d.current_is_dir():
|
||||||
print("Is directory: " + file_name)
|
print("Found directory: " + file_name)
|
||||||
else:
|
else:
|
||||||
print("Is File:" + file_name)
|
print("Found file:" + file_name)
|
||||||
file_name = d.get_next()
|
file_name = d.get_next()
|
||||||
else:
|
else:
|
||||||
print("Some open Error, maybe directory not found?")
|
print("Some open Error, maybe directory not found?")
|
||||||
|
[/codeblock]
|
||||||
</description>
|
</description>
|
||||||
<methods>
|
<methods>
|
||||||
<method name="open">
|
<method name="open">
|
||||||
|
@ -12950,7 +12950,6 @@ Returns an empty String "" at the end of the list.
|
||||||
<description>
|
<description>
|
||||||
Connect to a host. This needs to be done before any requests are sent.
|
Connect to a host. This needs to be done before any requests are sent.
|
||||||
The host should not have http:// prepended but will strip the protocol identifier if provided.
|
The host should not have http:// prepended but will strip the protocol identifier if provided.
|
||||||
|
|
||||||
verify_host will check the SSL identity of the host if set to true.
|
verify_host will check the SSL identity of the host if set to true.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
@ -12974,11 +12973,13 @@ verify_host will check the SSL identity of the host if set to true.
|
||||||
<description>
|
<description>
|
||||||
Sends a request to the connected host. The url is what is normally behind the hostname, i.e. in [code]http://somehost.com/index.php[/code], url would be "index.php".
|
Sends a request to the connected host. The url is what is normally behind the hostname, i.e. in [code]http://somehost.com/index.php[/code], url would be "index.php".
|
||||||
Headers are HTTP request headers.
|
Headers are HTTP request headers.
|
||||||
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]
|
||||||
var fields = {"username" : "user", "password" : "pass"}
|
var fields = {"username" : "user", "password" : "pass"}
|
||||||
var queryString = httpClient.query_string_from_dict(fields)
|
var queryString = httpClient.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(queryString.length())]
|
||||||
var result = httpClient.request(httpClient.METHOD_POST, "index.php", headers, queryString)
|
var result = httpClient.request(httpClient.METHOD_POST, "index.php", headers, queryString)
|
||||||
|
[/codeblock]
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="send_body_text">
|
<method name="send_body_text">
|
||||||
|
@ -13086,10 +13087,12 @@ verify_host will check the SSL identity of the host if set to true.
|
||||||
<argument index="0" name="fields" type="Dictionary">
|
<argument index="0" name="fields" type="Dictionary">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
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]
|
||||||
var fields = {"username": "user", "password": "pass"}
|
var fields = {"username": "user", "password": "pass"}
|
||||||
String queryString = httpClient.query_string_from_dict(fields)
|
String queryString = httpClient.query_string_from_dict(fields)
|
||||||
returns:= "username=user&password=pass"
|
returns:= "username=user&password=pass"
|
||||||
|
[/codeblock]
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
|
|
|
@ -100,7 +100,7 @@ def make_class_list(class_list, columns):
|
||||||
|
|
||||||
def rstize_text(text,cclass):
|
def rstize_text(text,cclass):
|
||||||
|
|
||||||
# Linebreak + tabs in the XML should become two line breaks
|
# Linebreak + tabs in the XML should become two line breaks unless in a "codeblock"
|
||||||
pos = 0
|
pos = 0
|
||||||
while True:
|
while True:
|
||||||
pos = text.find('\n', pos)
|
pos = text.find('\n', pos)
|
||||||
|
@ -112,6 +112,38 @@ def rstize_text(text,cclass):
|
||||||
pos += 1
|
pos += 1
|
||||||
post_text = text[pos+1:]
|
post_text = text[pos+1:]
|
||||||
|
|
||||||
|
# Handle codeblocks
|
||||||
|
if post_text.startswith("[codeblock]"):
|
||||||
|
end_pos = post_text.find("[/codeblock]")
|
||||||
|
if end_pos == -1:
|
||||||
|
sys.exit("ERROR! [codeblock] without a closing tag!")
|
||||||
|
|
||||||
|
code_text = post_text[len("[codeblock]"):end_pos]
|
||||||
|
post_text = post_text[end_pos:]
|
||||||
|
|
||||||
|
# Remove extraneous tabs
|
||||||
|
code_pos = 0
|
||||||
|
while True:
|
||||||
|
code_pos = code_text.find('\n', code_pos)
|
||||||
|
if code_pos == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
to_skip = 0
|
||||||
|
while code_pos+to_skip+1 < len(code_text) and code_text[code_pos+to_skip+1] == '\t':
|
||||||
|
to_skip += 1
|
||||||
|
|
||||||
|
if len(code_text[code_pos+to_skip+1:])==0:
|
||||||
|
code_text = code_text[:code_pos] + "\n"
|
||||||
|
code_pos += 1
|
||||||
|
else:
|
||||||
|
code_text = code_text[:code_pos] + "\n " + code_text[code_pos+to_skip+1:]
|
||||||
|
code_pos += 5 - to_skip
|
||||||
|
|
||||||
|
text = pre_text + "\n[codeblock]" + code_text + post_text
|
||||||
|
pos += len("\n[codeblock]" + code_text)
|
||||||
|
|
||||||
|
# Handle normal text
|
||||||
|
else:
|
||||||
text = pre_text + "\n\n" + post_text
|
text = pre_text + "\n\n" + post_text
|
||||||
pos += 2
|
pos += 2
|
||||||
|
|
||||||
|
@ -179,6 +211,13 @@ def rstize_text(text,cclass):
|
||||||
tag_text = ''
|
tag_text = ''
|
||||||
elif cmd == '/center':
|
elif cmd == '/center':
|
||||||
tag_text = ''
|
tag_text = ''
|
||||||
|
elif cmd == 'codeblock':
|
||||||
|
tag_text = '\n::\n'
|
||||||
|
elif cmd == '/codeblock':
|
||||||
|
tag_text = ''
|
||||||
|
# Strip newline if the tag was alone on one
|
||||||
|
if pre_text[-1] == '\n':
|
||||||
|
pre_text = pre_text[:-1]
|
||||||
elif cmd == 'br':
|
elif cmd == 'br':
|
||||||
# Make a new paragraph instead of a linebreak, rst is not so linebreak friendly
|
# Make a new paragraph instead of a linebreak, rst is not so linebreak friendly
|
||||||
tag_text = '\n\n'
|
tag_text = '\n\n'
|
||||||
|
@ -310,6 +349,10 @@ def make_rst_class(node):
|
||||||
|
|
||||||
f = open("class_"+name.lower() + '.rst', 'wb')
|
f = open("class_"+name.lower() + '.rst', 'wb')
|
||||||
|
|
||||||
|
# Warn contributors not to edit this file directly
|
||||||
|
f.write(".. Generated automatically by doc/tools/makerst.py in Godot's source tree.\n")
|
||||||
|
f.write(".. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.\n\n")
|
||||||
|
|
||||||
f.write(".. _class_"+name+":\n\n")
|
f.write(".. _class_"+name+":\n\n")
|
||||||
f.write(make_heading(name, '='))
|
f.write(make_heading(name, '='))
|
||||||
|
|
||||||
|
|
|
@ -1201,7 +1201,7 @@ void EditorHelp::_add_text(const String& p_bbcode) {
|
||||||
class_desc->push_font(get_font("italic","Fonts"));
|
class_desc->push_font(get_font("italic","Fonts"));
|
||||||
pos=brk_end+1;
|
pos=brk_end+1;
|
||||||
tag_stack.push_front(tag);
|
tag_stack.push_front(tag);
|
||||||
} else if (tag=="code") {
|
} else if (tag=="code" || tag=="codeblock") {
|
||||||
|
|
||||||
//use monospace font
|
//use monospace font
|
||||||
class_desc->push_font(get_font("source","EditorFonts"));
|
class_desc->push_font(get_font("source","EditorFonts"));
|
||||||
|
|
Loading…
Reference in a new issue