rolfedh-doc-utils 0.1.18__py3-none-any.whl → 0.1.19__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,6 +39,7 @@ def process_file(file_path: Path, dry_run: bool = False, verbose: bool = False)
39
39
  changes_made = False
40
40
  in_block = False # Track if we're inside a block (admonition, listing, etc.)
41
41
  in_conditional = False # Track if we're inside a conditional block
42
+ in_comment_block = False # Track if we're inside a //// comment block
42
43
 
43
44
  for i, current_line in enumerate(lines):
44
45
  prev_line = lines[i-1] if i > 0 else ""
@@ -48,9 +49,11 @@ def process_file(file_path: Path, dry_run: bool = False, verbose: bool = False)
48
49
  if re.match(r'^(ifdef::|ifndef::)', current_line):
49
50
  in_conditional = True
50
51
  # Add blank line before conditional if needed
52
+ # Don't add if previous line is a comment (they form a logical unit)
51
53
  if (prev_line and
52
54
  not re.match(r'^\s*$', prev_line) and
53
- not re.match(r'^(ifdef::|ifndef::|endif::)', prev_line)):
55
+ not re.match(r'^(ifdef::|ifndef::|endif::)', prev_line) and
56
+ not re.match(r'^//', prev_line)):
54
57
  new_lines.append("")
55
58
  changes_made = True
56
59
  if verbose:
@@ -70,19 +73,55 @@ def process_file(file_path: Path, dry_run: bool = False, verbose: bool = False)
70
73
  if verbose:
71
74
  messages.append(" Added blank line after conditional block")
72
75
 
76
+ # Check for comment block delimiters (////)
77
+ elif re.match(r'^////+$', current_line):
78
+ in_comment_block = not in_comment_block # Toggle comment block state
79
+ new_lines.append(current_line)
80
+
81
+ # If we're closing a comment block, add blank line after if needed
82
+ if not in_comment_block:
83
+ if (next_line and
84
+ not re.match(r'^\s*$', next_line) and
85
+ not re.match(r'^////+$', next_line)):
86
+ new_lines.append("")
87
+ changes_made = True
88
+ if verbose:
89
+ messages.append(" Added blank line after comment block")
90
+
73
91
  # Check for block delimiters (====, ----, ...., ____)
74
92
  # These are used for admonitions, listing blocks, literal blocks, etc.
75
93
  elif re.match(r'^(====+|----+|\.\.\.\.+|____+)$', current_line):
76
94
  in_block = not in_block # Toggle block state
77
95
  new_lines.append(current_line)
96
+
97
+ # Check for role blocks ([role="..."])
98
+ # Role blocks don't need special spacing - they're followed directly by content
99
+ elif not in_block and not in_comment_block and re.match(r'^\[role=', current_line):
100
+ new_lines.append(current_line)
101
+
102
+ # Check for block titles (.Title)
103
+ elif not in_block and not in_comment_block and re.match(r'^\.[A-Z]', current_line):
104
+ # Add blank line before block title if needed
105
+ if (prev_line and
106
+ not re.match(r'^\s*$', prev_line) and
107
+ not re.match(r'^=+\s+', prev_line) and
108
+ not re.match(r'^\[role=', prev_line)): # Don't add if previous is heading, empty, or role block
109
+ new_lines.append("")
110
+ changes_made = True
111
+ if verbose:
112
+ truncated = current_line[:50] + "..." if len(current_line) > 50 else current_line
113
+ messages.append(f" Added blank line before block title: {truncated}")
114
+ new_lines.append(current_line)
115
+
78
116
  # Check if current line is a heading (but not if we're in a block)
79
117
  elif not in_block and re.match(r'^=+\s+', current_line):
80
118
  new_lines.append(current_line)
81
119
 
82
- # Check if next line is not empty and not another heading
120
+ # Check if next line is not empty, not another heading, and not a comment block
83
121
  if (next_line and
84
122
  not re.match(r'^=+\s+', next_line) and
85
- not re.match(r'^\s*$', next_line)):
123
+ not re.match(r'^\s*$', next_line) and
124
+ not re.match(r'^////+$', next_line)): # Don't add if next is comment block
86
125
  new_lines.append("")
87
126
  changes_made = True
88
127
  if verbose:
@@ -98,15 +137,19 @@ def process_file(file_path: Path, dry_run: bool = False, verbose: bool = False)
98
137
  # Check if next line is an include directive
99
138
  if next_line and re.match(r'^include::', next_line):
100
139
  # This comment belongs to the include, add blank line before comment if needed
140
+ # This includes when previous line is an include (to separate include blocks)
101
141
  if (prev_line and
102
142
  not re.match(r'^\s*$', prev_line) and
103
143
  not re.match(r'^//', prev_line) and
104
- not re.match(r'^:', prev_line)): # Don't add if previous is attribute
144
+ not re.match(r'^:', prev_line)):
105
145
  new_lines.append("")
106
146
  changes_made = True
107
147
  if verbose:
108
148
  messages.append(" Added blank line before comment above include")
109
- new_lines.append(current_line)
149
+ new_lines.append(current_line)
150
+ else:
151
+ # Standalone comment, just add it
152
+ new_lines.append(current_line)
110
153
 
111
154
  # Check if current line is an attribute (starts with :)
112
155
  elif re.match(r'^:', current_line):
@@ -125,7 +168,10 @@ def process_file(file_path: Path, dry_run: bool = False, verbose: bool = False)
125
168
  changes_made = True
126
169
  if verbose:
127
170
  messages.append(" Added blank line before attribute above include")
128
- new_lines.append(current_line)
171
+ new_lines.append(current_line)
172
+ else:
173
+ # Standalone attribute, just add it
174
+ new_lines.append(current_line)
129
175
 
130
176
  # Check if current line is an include directive
131
177
  elif re.match(r'^include::', current_line):
@@ -155,10 +201,10 @@ def process_file(file_path: Path, dry_run: bool = False, verbose: bool = False)
155
201
  if not (is_attribute_include and is_near_h1):
156
202
  # Don't add blank line if there's a comment or attribute above (it was handled by the comment/attribute logic)
157
203
  if not has_comment_above and not has_attribute_above:
158
- # Add blank line before include if previous line is not empty and not an include
204
+ # Add blank line before include if previous line is not empty
205
+ # This includes adding blank lines between consecutive includes
159
206
  if (prev_line and
160
- not re.match(r'^\s*$', prev_line) and
161
- not re.match(r'^include::', prev_line)):
207
+ not re.match(r'^\s*$', prev_line)):
162
208
  new_lines.append("")
163
209
  changes_made = True
164
210
  if verbose:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rolfedh-doc-utils
3
- Version: 0.1.18
3
+ Version: 0.1.19
4
4
  Summary: CLI tools for AsciiDoc documentation projects
5
5
  Author: Rolfe Dlugy-Hegwer
6
6
  License: MIT License
@@ -9,7 +9,7 @@ validate_links.py,sha256=KmN4dULwLiLM2lUyteXwbBuTuQHcNkCq0nhiaZ48BtI,6013
9
9
  doc_utils/__init__.py,sha256=qqZR3lohzkP63soymrEZPBGzzk6-nFzi4_tSffjmu_0,74
10
10
  doc_utils/extract_link_attributes.py,sha256=U0EvPZReJQigNfbT-icBsVT6Li64hYki5W7MQz6qqbc,22743
11
11
  doc_utils/file_utils.py,sha256=fpTh3xx759sF8sNocdn_arsP3KAv8XA6cTQTAVIZiZg,4247
12
- doc_utils/format_asciidoc_spacing.py,sha256=XnVJekaj39aDzjV3xFKl58flM41AaJzejxNYJIIAMz0,10139
12
+ doc_utils/format_asciidoc_spacing.py,sha256=QMeEGkbcZnK7MJDWdi6s_ct5LQ5A4zOfDaDwg8yrli0,12528
13
13
  doc_utils/replace_link_attributes.py,sha256=gmAs68_njBqEz-Qni-UGgeYEDTMxlTWk_IOm76FONNE,7279
14
14
  doc_utils/scannability.py,sha256=XwlmHqDs69p_V36X7DLjPTy0DUoLszSGqYjJ9wE-3hg,982
15
15
  doc_utils/spinner.py,sha256=lJg15qzODiKoR0G6uFIk2BdVNgn9jFexoTRUMrjiWvk,3554
@@ -19,9 +19,9 @@ doc_utils/unused_attributes.py,sha256=OHyAdaBD7aNo357B0SLBN5NC_jNY5TWXMwgtfJNh3X
19
19
  doc_utils/unused_images.py,sha256=nqn36Bbrmon2KlGlcaruNjJJvTQ8_9H0WU9GvCW7rW8,1456
20
20
  doc_utils/validate_links.py,sha256=iBGXnwdeLlgIT3fo3v01ApT5k0X2FtctsvkrE6E3VMk,19610
21
21
  doc_utils/version_check.py,sha256=1ySC6Au21OqUMZr7AkIa3nMNh3M6wLQmPQCi-ZFIqoE,6338
22
- rolfedh_doc_utils-0.1.18.dist-info/licenses/LICENSE,sha256=vLxtwMVOJA_hEy8b77niTkdmQI9kNJskXHq0dBS36e0,1075
23
- rolfedh_doc_utils-0.1.18.dist-info/METADATA,sha256=0MRwKnjHS1EEX5--O9m0UQVvQpYSICZ1k-VSTX3VhQA,7824
24
- rolfedh_doc_utils-0.1.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- rolfedh_doc_utils-0.1.18.dist-info/entry_points.txt,sha256=2J4Ojc3kkuArpe2xcUOPc0LxSWCmnctvw8hy8zpnbO4,418
26
- rolfedh_doc_utils-0.1.18.dist-info/top_level.txt,sha256=1w0JWD7w7gnM5Sga2K4fJieNZ7CHPTAf0ozYk5iIlmo,182
27
- rolfedh_doc_utils-0.1.18.dist-info/RECORD,,
22
+ rolfedh_doc_utils-0.1.19.dist-info/licenses/LICENSE,sha256=vLxtwMVOJA_hEy8b77niTkdmQI9kNJskXHq0dBS36e0,1075
23
+ rolfedh_doc_utils-0.1.19.dist-info/METADATA,sha256=qxw_UIKk4_6niK9TY1YaR3a4Notj-HBRthbk1pBNAB0,7824
24
+ rolfedh_doc_utils-0.1.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ rolfedh_doc_utils-0.1.19.dist-info/entry_points.txt,sha256=2J4Ojc3kkuArpe2xcUOPc0LxSWCmnctvw8hy8zpnbO4,418
26
+ rolfedh_doc_utils-0.1.19.dist-info/top_level.txt,sha256=1w0JWD7w7gnM5Sga2K4fJieNZ7CHPTAf0ozYk5iIlmo,182
27
+ rolfedh_doc_utils-0.1.19.dist-info/RECORD,,