Skip to content

Commit

Permalink
Allow cfdocs integration to be disabled
Browse files Browse the repository at this point in the history
also added some backtick styling
closes #112
  • Loading branch information
jcberquist committed Apr 16, 2018
1 parent 08303d6 commit ecf8574
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions settings/cfml_package.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"cfml_non_closing_tags": ["cfabort","cfargument","cfbreak","cfcontent","cfcontinue","cfcookie","cfdirectory","cfdump","cfelse","cfelseif","cfexecute","cfexit","cffile","cfflush","cfheader","cfhttpparam","cfimage","cfimport","cfinclude","cfindex","cfinput","cfinvokeargument","cflocation","cflog","cfloginuser","cflogout","cfmailparam","cfobject","cfobjectcache","cfparam","cfpop","cfprocessingdirective","cfprocparam","cfprocresult","cfproperty","cfqueryparam","cfrethrow","cfreturn","cfschedule","cfsearch","cfset","cfsetting","cfthrow"],
"html_non_closing_tags": ["area","base","br","col","command","embed","hr","img","input","link","meta","param","source","track","wbr"],

// if this is set to false, cfdocs data will not be used
"cfdocs_enabled": true,

// file path to local version of cfdocs json data folder
// should end with trailing "/" - e.g. 'C:/github/cfdocs/data/en/'
"cfdocs_path": null,
Expand Down
12 changes: 10 additions & 2 deletions src/cfdocs/cfdocs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sublime
import json
import re
import time
import urllib.request
import urllib.error
Expand Down Expand Up @@ -38,6 +39,9 @@ def get_inline_documentation(cfml_view, doc_type):
doc_regions = None
doc_priority = 0

if not utils.get_setting("cfdocs_enabled"):
return None

# functions
if cfml_view.view.match_selector(cfml_view.position, "meta.function-call.support.cfml"):
doc_name, function_name_region, function_args_region = cfml_view.get_function_call(cfml_view.position, True)
Expand Down Expand Up @@ -71,6 +75,9 @@ def get_inline_documentation(cfml_view, doc_type):


def get_completion_docs(cfml_view):
if not utils.get_setting("cfdocs_enabled"):
return None

if cfml_view.function_call_params is None:
return None

Expand All @@ -92,7 +99,6 @@ def get_cfdoc(function_or_tag):
return load_cfdoc(function_or_tag)
return fetch_cfdoc(function_or_tag)


def load_cfdoc(function_or_tag):
global CFDOCS_CACHE
file_path = function_or_tag + ".json"
Expand Down Expand Up @@ -184,6 +190,8 @@ def build_cfdoc(function_or_tag, data):
cfdoc["html"]["body"] += documentation_helpers.card(header, body)
cfdoc["html"]["body"] += "\n"

cfdoc["html"]["body"] = re.sub(r'`([^`\n<>]+)`', r'<span class="code">\1</span>', cfdoc["html"]["body"])

return cfdoc


Expand Down Expand Up @@ -223,7 +231,7 @@ def build_cfdoc_header(data, include_params=True):


def build_cfdoc_error(function_or_tag, data):
cfdoc = {"styles": STYLES, "adaptive_styles": ADAPTIVE_STYLES, "html": {}}
cfdoc = {"side_color": SIDE_COLOR, "html": {}}
cfdoc["html"]["side_color"] = "#F2777A"
cfdoc["html"]["header_bg_color"] = "#FFFFFF"
cfdoc["html"]["header"] = "Uh oh!"
Expand Down
4 changes: 2 additions & 2 deletions src/inline_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def generate_documentation(view, docs, current_index, doc_type):

if "styles" in docs[current_index].doc_html_variables:
doc_html_variables.update(docs[current_index].doc_html_variables["styles"])

styles_by_selector = minihtml.get_selector_style_map(view, SELECTORS)
for key in styles_by_selector:
style = styles_by_selector[key]
Expand Down Expand Up @@ -145,7 +145,7 @@ def display_documentation(view, docs, doc_type, pt=-1, current_index=0):
view.update_popup(doc_html)
else:
doc_window = "completion_doc"
view.show_popup(doc_html, flags=sublime.COOPERATE_WITH_AUTO_COMPLETE, on_navigate=on_navigate, on_hide=lambda: on_hide(view, doc_region_id))
view.show_popup(doc_html, flags=sublime.COOPERATE_WITH_AUTO_COMPLETE, max_width=768, on_navigate=on_navigate, on_hide=lambda: on_hide(view, doc_region_id))
else:
if doc_regions and utils.get_setting("inline_doc_regions_highlight"):
view.add_regions(doc_region_id, merge_regions(doc_regions), "source", flags=sublime.DRAW_NO_FILL)
Expand Down
6 changes: 4 additions & 2 deletions templates/inline_documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@
color: color(var(--foreground) blend(var(--background) 95%));
}
.code {
background-color: color(var(--background) blend(var(--foreground) 80%));
color: color(var(--foreground) blend(var(--background) 95%));
background-color: var(--background);
color: var(--foreground);
padding: 0 2px;
border-radius: 2px;
}

.pagination {
Expand Down

0 comments on commit ecf8574

Please sign in to comment.