Skip to content

Commit 20fdb24

Browse files
committed
Updated LDoc.
Utilize the first documentation line instead of making it a blank header and added LDoc for local functions and tables.
1 parent 603c72d commit 20fdb24

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

init.lua

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
-- Copyright 2015-2023 Mitchell. See LICENSE.
22

3-
local M = {}
4-
5-
---
6-
-- Two-way file comparison for Textadept.
3+
--- Two-way file comparison for Textadept.
74
--
85
-- Install this module by copying it into your *~/.textadept/modules/* directory or Textadept's
96
-- *modules/* directory, and then putting the following in your *~/.textadept/init.lua*:
@@ -49,6 +46,7 @@ local M = {}
4946
-- Ctrl+Alt+< | ^⌘< | None | Merge left
5047
-- Ctrl+Alt+> | ^⌘> | None | Merge right
5148
-- @module file_diff
49+
local M = {}
5250

5351
--- The marker for line additions.
5452
M.MARK_ADDITION = _SCINTILLA.new_marker_number()
@@ -93,7 +91,7 @@ local DELETE, INSERT = 0, 1 -- C++: "enum Operation {DELETE, INSERT, EQUAL};"
9391

9492
local view1, view2
9593

96-
-- Clear markers, indicators, and placeholder lines.
94+
--- Clear markers, indicators, and placeholder lines.
9795
-- Used when re-marking changes or finished comparing.
9896
local function clear_marked_changes()
9997
local buffer1 = _VIEWS[view1] and view1.buffer
@@ -117,7 +115,7 @@ local function clear_marked_changes()
117115
end
118116

119117
local synchronizing = false
120-
-- Synchronize the scroll and line position of the other buffer.
118+
--- Synchronize the scroll and line position of the other buffer.
121119
local function synchronize()
122120
synchronizing = true
123121
local line = buffer:line_from_position(buffer.current_pos)
@@ -131,14 +129,14 @@ local function synchronize()
131129
synchronizing = false
132130
end
133131

134-
-- Returns the number of lines contained in the given string.
132+
--- Returns the number of lines contained in the given string.
135133
local function count_lines(text)
136134
local lines = 1
137135
for _ in text:gmatch('\n') do lines = lines + 1 end
138136
return lines
139137
end
140138

141-
-- Mark the differences between the two buffers.
139+
--- Mark the differences between the two buffers.
142140
local function mark_changes()
143141
if not _VIEWS[view1] or not _VIEWS[view2] then return end
144142
clear_marked_changes() -- clear previous marks
@@ -275,8 +273,7 @@ end
275273

276274
local starting_diff = false
277275

278-
---
279-
-- Highlight differences between files *file1* and *file2*, or the user-selected files.
276+
--- Highlight differences between files *file1* and *file2*, or the user-selected files.
280277
-- @param file1 Optional name of the older file. If `-`, uses the current buffer. If `nil`,
281278
-- the user is prompted for a file.
282279
-- @param file2 Optional name of the newer file. If `-`, uses the current buffer. If `nil`,
@@ -313,7 +310,7 @@ function M.start(file1, file2, horizontal)
313310
if file1 == '-' or file2 == '-' then mark_changes() end
314311
end
315312

316-
-- Stops comparing.
313+
--- Stops comparing.
317314
local function stop()
318315
if not _VIEWS[view1] or not _VIEWS[view2] then return end
319316
clear_marked_changes()
@@ -324,7 +321,7 @@ end
324321
events.connect(events.BUFFER_BEFORE_SWITCH, function() if not starting_diff then stop() end end)
325322
events.connect(events.BUFFER_DELETED, stop)
326323

327-
-- Retrieves the equivalent of line number *line* in the other buffer.
324+
--- Retrieves the equivalent of line number *line* in the other buffer.
328325
-- @param line Line to get the synchronized equivalent of in the other buffer.
329326
-- @return line
330327
local function get_synchronized_line(line)
@@ -335,8 +332,7 @@ local function get_synchronized_line(line)
335332
return line
336333
end
337334

338-
---
339-
-- Jumps to the next or previous difference between the two files depending on boolean *next*.
335+
--- Jumps to the next or previous difference between the two files depending on boolean *next*.
340336
-- [`file_diff.start()`]() must have been called previously.
341337
-- @param next Whether to go to the next or previous difference relative to the current line.
342338
function M.goto_change(next)
@@ -406,8 +402,7 @@ function M.goto_change(next)
406402
view:vertical_center_caret()
407403
end
408404

409-
---
410-
-- Merges a change from one buffer to another, depending on the change under the caret and the
405+
--- Merges a change from one buffer to another, depending on the change under the caret and the
411406
-- merge direction.
412407
-- @param left Whether to merge from right to left or left to right.
413408
function M.merge(left)
@@ -558,8 +553,7 @@ return M
558553

559554
-- The function below is a Lua C function.
560555

561-
---
562-
-- Returns a list that represents the differences between strings *text1* and *text2*.
556+
--- Returns a list that represents the differences between strings *text1* and *text2*.
563557
-- Each consecutive pair of elements in the returned list represents a "diff". The first element
564558
-- is an integer: 0 for a deletion, 1 for an insertion, and 2 for equality. The second element
565559
-- is the associated diff text.

0 commit comments

Comments
 (0)