Skip to content

Commit 603c72d

Browse files
committed
Switched documentation format to LDoc from LuaDoc and updated for Textadept 12.0.
LuaDoc is obsolete and LDoc is the recommended replacement.
1 parent 1dc4551 commit 603c72d

File tree

3 files changed

+49
-66
lines changed

3 files changed

+49
-66
lines changed

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,10 @@ endif()
5858

5959
# Documentation.
6060
get_filename_component(ta_dir ${src}/../../ ABSOLUTE)
61-
add_custom_target(docs DEPENDS README.md luadoc)
61+
add_custom_target(docs DEPENDS README.md)
6262
add_custom_command(OUTPUT ${src}/README.md
63-
COMMAND luadoc --doclet markdowndoc ${src}/init.lua > ${src}/README.md
63+
COMMAND ldoc --filter markdowndoc.ldoc ${src}/init.lua > ${src}/README.md
6464
COMMAND sed -i -e "1,+4d" -e "6c# File Diff" -e "7d" -e "s/^##/#/;" ${src}/README.md
6565
DEPENDS init.lua
6666
WORKING_DIRECTORY ${ta_dir}/scripts
6767
VERBATIM)
68-
add_custom_target(luadoc DEPENDS tags api)
69-
add_custom_command(OUTPUT ${src}/tags ${src}/api
70-
COMMAND luadoc -d ${src} --doclet tadoc ${src}/init.lua --ta-home=${ta_dir}
71-
DEPENDS init.lua
72-
WORKING_DIRECTORY ${ta_dir}/modules/lua)

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# File Diff
2+
---
23

34
Two-way file comparison for Textadept.
45

@@ -46,39 +47,38 @@ Ctrl+Alt+, | ^⌘, | None | Goto previous difference
4647
Ctrl+Alt+< | ^⌘< | None | Merge left
4748
Ctrl+Alt+> | ^⌘> | None | Merge right
4849

49-
5050
## Fields defined by `file_diff`
5151

5252
<a id="file_diff.INDIC_ADDITION"></a>
53-
### `file_diff.INDIC_ADDITION` (number)
53+
### `file_diff.INDIC_ADDITION`
5454

5555
The indicator number for text added within lines.
5656

5757
<a id="file_diff.INDIC_DELETION"></a>
58-
### `file_diff.INDIC_DELETION` (number)
58+
### `file_diff.INDIC_DELETION`
5959

6060
The indicator number for text deleted within lines.
6161

6262
<a id="file_diff.MARK_ADDITION"></a>
63-
### `file_diff.MARK_ADDITION` (number)
63+
### `file_diff.MARK_ADDITION`
6464

6565
The marker for line additions.
6666

6767
<a id="file_diff.MARK_DELETION"></a>
68-
### `file_diff.MARK_DELETION` (number)
68+
### `file_diff.MARK_DELETION`
6969

7070
The marker for line deletions.
7171

7272
<a id="file_diff.MARK_MODIFICATION"></a>
73-
### `file_diff.MARK_MODIFICATION` (number)
73+
### `file_diff.MARK_MODIFICATION`
7474

7575
The marker for line modifications.
7676

7777

7878
## Functions defined by `file_diff`
7979

8080
<a id="_G.diff"></a>
81-
### `_G.diff`(*text1, text2*)
81+
### `_G.diff`(*text1*, *text2*)
8282

8383
Returns a list that represents the differences between strings *text1* and *text2*.
8484
Each consecutive pair of elements in the returned list represents a "diff". The first element
@@ -87,17 +87,18 @@ is the associated diff text.
8787

8888
Parameters:
8989

90-
* *`text1`*: String to compare against.
91-
* *`text2`*: String to compare.
90+
- *text1*: String to compare against.
91+
- *text2*: String to compare.
9292

9393
Usage:
9494

95-
* `diffs = diff(text1, text2)
96-
for i = 1, #diffs, 2 do print(diffs[i], diffs[i + 1]) end`
95+
- `diffs = diff(text1, text2)
96+
for i = 1, #diffs, 2 do print(diffs[i], diffs[i + 1]) end
97+
`
9798

9899
Return:
99100

100-
* list of differences
101+
- list of differences
101102

102103
<a id="file_diff.goto_change"></a>
103104
### `file_diff.goto_change`(*next*)
@@ -107,7 +108,7 @@ Jumps to the next or previous difference between the two files depending on bool
107108

108109
Parameters:
109110

110-
* *`next`*: Whether to go to the next or previous difference relative to the current line.
111+
- *next*: Whether to go to the next or previous difference relative to the current line.
111112

112113
<a id="file_diff.merge"></a>
113114
### `file_diff.merge`(*left*)
@@ -117,21 +118,21 @@ merge direction.
117118

118119
Parameters:
119120

120-
* *`left`*: Whether to merge from right to left or left to right.
121+
- *left*: Whether to merge from right to left or left to right.
121122

122123
<a id="file_diff.start"></a>
123-
### `file_diff.start`(*file1, file2, horizontal*)
124+
### `file_diff.start`(*file1*, *file2*, *horizontal*)
124125

125126
Highlight differences between files *file1* and *file2*, or the user-selected files.
126127

127128
Parameters:
128129

129-
* *`file1`*: Optional name of the older file. If `-`, uses the current buffer. If `nil`,
130-
the user is prompted for a file.
131-
* *`file2`*: Optional name of the newer file. If `-`, uses the current buffer. If `nil`,
132-
the user is prompted for a file.
133-
* *`horizontal`*: Optional flag specifying whether or not to split the view horizontally. The
134-
default value is `false`, comparing the two files side-by-side.
130+
- *file1*: Optional name of the older file. If `-`, uses the current buffer. If `nil`,
131+
the user is prompted for a file.
132+
- *file2*: Optional name of the newer file. If `-`, uses the current buffer. If `nil`,
133+
the user is prompted for a file.
134+
- *horizontal*: Optional flag specifying whether or not to split the view horizontally. The
135+
default value is `false`, comparing the two files side-by-side.
135136

136137

137138
---

init.lua

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
local M = {}
44

5-
--[[ This comment is for LuaDoc.
65
---
76
-- Two-way file comparison for Textadept.
87
--
@@ -49,24 +48,18 @@ local M = {}
4948
-- Ctrl+Alt+, | ^⌘, | None | Goto previous difference
5049
-- Ctrl+Alt+< | ^⌘< | None | Merge left
5150
-- Ctrl+Alt+> | ^⌘> | None | Merge right
52-
--
53-
-- @field MARK_ADDITION (number)
54-
-- The marker for line additions.
55-
-- @field MARK_DELETION (number)
56-
-- The marker for line deletions.
57-
-- @field MARK_MODIFICATION (number)
58-
-- The marker for line modifications.
59-
-- @field INDIC_ADDITION (number)
60-
-- The indicator number for text added within lines.
61-
-- @field INDIC_DELETION (number)
62-
-- The indicator number for text deleted within lines.
63-
module('file_diff')]]
51+
-- @module file_diff
6452

65-
M.MARK_ADDITION = _SCINTILLA.next_marker_number()
66-
M.MARK_DELETION = _SCINTILLA.next_marker_number()
67-
M.MARK_MODIFICATION = _SCINTILLA.next_marker_number()
68-
M.INDIC_ADDITION = _SCINTILLA.next_indic_number()
69-
M.INDIC_DELETION = _SCINTILLA.next_indic_number()
53+
--- The marker for line additions.
54+
M.MARK_ADDITION = _SCINTILLA.new_marker_number()
55+
--- The marker for line deletions.
56+
M.MARK_DELETION = _SCINTILLA.new_marker_number()
57+
--- The marker for line modifications.
58+
M.MARK_MODIFICATION = _SCINTILLA.new_marker_number()
59+
--- The indicator number for text added within lines.
60+
M.INDIC_ADDITION = _SCINTILLA.new_indic_number()
61+
--- The indicator number for text deleted within lines.
62+
M.INDIC_DELETION = _SCINTILLA.new_indic_number()
7063
local MARK_ADDITION = M.MARK_ADDITION
7164
local MARK_DELETION = M.MARK_DELETION
7265
local MARK_MODIFICATION = M.MARK_MODIFICATION
@@ -290,7 +283,6 @@ local starting_diff = false
290283
-- the user is prompted for a file.
291284
-- @param horizontal Optional flag specifying whether or not to split the view horizontally. The
292285
-- default value is `false`, comparing the two files side-by-side.
293-
-- @name start
294286
function M.start(file1, file2, horizontal)
295287
file1 = file1 or ui.dialogs.open{
296288
title = _L['Select the first file to compare'],
@@ -347,7 +339,6 @@ end
347339
-- Jumps to the next or previous difference between the two files depending on boolean *next*.
348340
-- [`file_diff.start()`]() must have been called previously.
349341
-- @param next Whether to go to the next or previous difference relative to the current line.
350-
-- @name goto_change
351342
function M.goto_change(next)
352343
if not _VIEWS[view1] or not _VIEWS[view2] then return end
353344
-- Determine the line to start on, keeping in mind the synchronized line numbers may be different.
@@ -419,7 +410,6 @@ end
419410
-- Merges a change from one buffer to another, depending on the change under the caret and the
420411
-- merge direction.
421412
-- @param left Whether to merge from right to left or left to right.
422-
-- @name merge
423413
function M.merge(left)
424414
if not _VIEWS[view1] or not _VIEWS[view2] then return end
425415
local buffer1, buffer2 = view1.buffer, view2.buffer
@@ -534,24 +524,21 @@ for i = 1, #m_tools - 1 do
534524
elseif found_area then
535525
local label = m_tools[i].title or m_tools[i][1]
536526
if 'Compare Files' < label:gsub('^_', '') or m_tools[i][1] == '' then
537-
-- LuaFormatter off
538527
table.insert(m_tools, i, {
539-
title = _L['Compare Files'],
540-
{_L['Compare Files...'], M.start},
541-
{_L['Compare This File With...'], function()
542-
if buffer.filename then M.start(buffer.filename) end
543-
end},
544-
{_L['Compare Buffers'], function() M.start('-', '-') end},
545-
{''},
528+
title = _L['Compare Files'], --
529+
{_L['Compare Files...'], M.start}, {
530+
_L['Compare This File With...'],
531+
function() if buffer.filename then M.start(buffer.filename) end end
532+
}, {_L['Compare Buffers'], function() M.start('-', '-') end}, --
533+
{''}, --
546534
{_L['Next Change'], function() M.goto_change(true) end},
547-
{_L['Previous Change'], M.goto_change},
548-
{''},
549-
{_L['Merge Left'], function() M.merge(true) end},
550-
{_L['Merge Right'], M.merge},
551-
{''},
535+
{_L['Previous Change'], M.goto_change}, --
536+
{''}, --
537+
{_L['Merge Left'], function() M.merge(true) end}, --
538+
{_L['Merge Right'], M.merge}, --
539+
{''}, --
552540
{_L['Stop Comparing'], stop}
553541
})
554-
-- LuaFormatter on
555542
break
556543
end
557544
end
@@ -569,7 +556,8 @@ end
569556

570557
return M
571558

572-
--[[ The function below is a Lua C function.
559+
-- The function below is a Lua C function.
560+
573561
---
574562
-- Returns a list that represents the differences between strings *text1* and *text2*.
575563
-- Each consecutive pair of elements in the returned list represents a "diff". The first element
@@ -580,5 +568,4 @@ return M
580568
-- @return list of differences
581569
-- @usage diffs = diff(text1, text2)
582570
-- for i = 1, #diffs, 2 do print(diffs[i], diffs[i + 1]) end
583-
function _G.diff(text1, text2) end
584-
]]
571+
-- @function _G.diff

0 commit comments

Comments
 (0)