Support another extensions like '.template'
@@ -128,7 +128,14 @@ def build_definitions_context(definitions, definitions_raw, root_folder):
start_line = attr_value.start_mark.line
end_line = attr_value.end_mark.line
# fix lines number for yaml and json files
- if file_path.endswith(".yaml") or file_path.endswith(".yml"):
+ first_line_index = 0
+ while not str.strip(definitions_raw[file_path][first_line_index][1]):
+ first_line_index += 1
+ # check if the file is a json file
+ if str.strip(definitions_raw[file_path][first_line_index][1])[0] is "{":
+ start_line += 1
+ end_line += 1
+ else:
current_line = str.strip(definitions_raw[file_path][start_line - 1][1])
while not current_line or current_line[0] is YAML_COMMENT_MARK:
start_line -= 1
@@ -137,9 +144,7 @@ def build_definitions_context(definitions, definitions_raw, root_folder):
while not current_line or current_line[0] is YAML_COMMENT_MARK:
end_line -= 1
current_line = str.strip(definitions_raw[file_path][end_line - 1][1])
- elif file_path.endswith(".json"):
- start_line += 1
- end_line += 1
+
code_lines = definitions_raw[file_path][start_line - 1: end_line]
file_abs_path = create_file_abs_path(root_folder, file_path)
dpath.new(definitions_context,
