Skip to content

Commit 44f0231

Browse files
committed
fix: insert_marker= is now start_marker= #77
1 parent 7ef82f5 commit 44f0231

File tree

9 files changed

+48
-27
lines changed

9 files changed

+48
-27
lines changed

changelog.d/20250419_192659_nedbat_title_in_template.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
Changed
1717
.......
1818

19-
- The ``output_file`` setting is now called ``changelog`` since some uses of
20-
scriv only read the file. An ``output_file`` entry in the config file will
21-
still work to set the name. Closes `issue 77`_.
19+
- Two settings have new names to better reflect what scriv does.
20+
The ``output_file`` setting is now called ``changelog`` and the
21+
``insert_marker`` setting is now called ``start_marker``.
22+
The old names will continue to work. Closes `issue 77`_.
2223

2324
.. _issue 77: https://github.com/nedbat/scriv/issues/77
2425

docs/commands.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ the new entry with the ``--title`` option.
139139
The output file is specified by the :ref:`config_changelog` setting. Scriv
140140
looks in the file for a special marker (usually in a comment) to determine
141141
where to insert the new entry. The marker is "scriv-insert-here", but can be
142-
changed with the :ref:`config_insert_marker` setting. Using a marker like
142+
changed with the :ref:`config_start_marker` setting. Using a marker like
143143
this, you can have your changelog be just part of a larger README file. If
144144
there is no marker in the file, the new entry is inserted at the top of the
145145
file.

docs/configuration.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,6 @@ The scriv configuration is available in a ``{{config}}`` object.
306306
Default: ``{{body}}``
307307

308308

309-
.. _config_insert_marker:
310-
311-
insert_marker
312-
-------------
313-
314-
A marker string indicating where in the changelog file new
315-
entries should be inserted.
316-
317-
Default: ``scriv-insert-here``
318-
319-
320309
.. _config_main_branches:
321310

322311
main_branches
@@ -373,6 +362,18 @@ not be collected.
373362
Default: ``README.*``
374363

375364

365+
.. _config_start_marker:
366+
367+
start_marker
368+
------------
369+
370+
A marker string indicating where in the changelog file new
371+
entries should be inserted. The old name for this setting is
372+
:ref:`insert_marker <deprecated_config>`.
373+
374+
Default: ``scriv-insert-here``
375+
376+
376377
.. _config_version:
377378

378379
version
@@ -385,7 +386,7 @@ source file.
385386

386387
Default: (empty)
387388

388-
.. [[[end]]] (checksum: acce6a163b5e8567a695069a8b5146e3)
389+
.. [[[end]]] (checksum: 1b528f5aa913cecca1337c5dda4aa206)
389390
390391
391392
.. _deprecated_config:
@@ -397,6 +398,7 @@ Some names in the config file have been updated. The old names will continue to
397398
work, but the new names are preferred:
398399

399400
- ``output_file`` is now ``changelog``.
401+
- ``insert_marker`` is now ``start_marker``.
400402

401403

402404
.. _git_settings:

src/scriv/changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def read(self) -> None:
6060
else:
6161
self.newline = f.newlines[0]
6262
before, marker, after = partition_lines(
63-
changelog_text, self.config.insert_marker
63+
changelog_text, self.config.start_marker
6464
)
6565
if marker:
6666
self.text_before = before + marker

src/scriv/config.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ class _Options:
8383
},
8484
)
8585

86-
insert_marker = attr.ib(
86+
start_marker = attr.ib(
8787
type=str,
8888
default="scriv-insert-here",
8989
metadata={
9090
"doc": """\
9191
A marker string indicating where in the changelog file new
92-
entries should be inserted.
92+
entries should be inserted. The old name for this setting is
93+
:ref:`insert_marker <deprecated_config>`.
9394
""",
9495
},
9596
)
@@ -223,6 +224,13 @@ class _Options:
223224
)
224225

225226

227+
# Map of old config names to new config names.
228+
REPLACED_NAMES = [
229+
("output_file", "changelog"),
230+
("insert_marker", "start_marker"),
231+
]
232+
233+
226234
@contextlib.contextmanager
227235
def validator_exceptions():
228236
"""
@@ -333,7 +341,8 @@ def read_one_config(self, configfile: str) -> None:
333341
scriv_data = parser[section_name]
334342
for attrdef in attr.fields(_Options):
335343
self.get_set_option(scriv_data, attrdef.name, attrdef.name)
336-
self.get_set_option(scriv_data, "output_file", "changelog")
344+
for old, new in REPLACED_NAMES:
345+
self.get_set_option(scriv_data, old, new)
337346

338347
def read_one_toml(self, tomlfile: str) -> None:
339348
"""
@@ -368,7 +377,8 @@ def read_one_toml(self, tomlfile: str) -> None:
368377
return
369378
for attrdef in attr.fields(_Options):
370379
self.get_set_option(scriv_data, attrdef.name, attrdef.name)
371-
self.get_set_option(scriv_data, "output_file", "changelog")
380+
for old, new in REPLACED_NAMES:
381+
self.get_set_option(scriv_data, old, new)
372382

373383
def resolve_value(self, value: str) -> str:
374384
"""

src/scriv/format_md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def parse_text(
1616

1717
# If there's an insert marker, start there.
1818
for lineno, line in enumerate(lines):
19-
if self.config.insert_marker in line:
19+
if self.config.start_marker in line:
2020
lines = lines[lineno + 1 :]
2121
break
2222

src/scriv/format_rst.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def parse_text(
5959

6060
# If there's an insert marker, start there.
6161
for lineno, line in enumerate(lines):
62-
if self.config.insert_marker in line:
62+
if self.config.start_marker in line:
6363
lines = lines[lineno + 1 :]
6464
break
6565
lines.append("")

tests/test_changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
)
7171
def test_round_trip(text, temp_dir):
7272
path = temp_dir / "foo.rst"
73-
config = Config(insert_marker="INSERT", end_marker="END")
73+
config = Config(start_marker="INSERT", end_marker="END")
7474
path.write_text(text)
7575
changelog = Changelog(path, config)
7676
changelog.read()

tests/test_config.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
[scriv]
1616
changelog = README.md
1717
categories = New, Different, Gone, Bad
18+
start_marker = FIRST!
1819
"""
1920

20-
OLD_CONFIG1 = CONFIG1.replace("changelog = ", "output_file = ")
21+
OLD_CONFIG1 = CONFIG1.replace("changelog = ", "output_file = ").replace(
22+
"start_marker = ", "insert_marker = "
23+
)
2124

2225
CONFIG2 = """\
2326
[someotherthing]
@@ -68,14 +71,17 @@
6871
"Gone",
6972
"Bad",
7073
]
74+
start_marker = "FIRST!"
7175
# other scriv options
7276
7377
["more stuff"]
7478
value = 17
7579
"""
7680
)
7781

78-
OLD_TOML_CONFIG = TOML_CONFIG.replace("changelog = ", "output_file = ")
82+
OLD_TOML_CONFIG = TOML_CONFIG.replace("changelog = ", "output_file = ").replace(
83+
"start_marker = ", "insert_marker = "
84+
)
7985

8086

8187
def test_defaults(temp_dir):
@@ -95,7 +101,7 @@ def test_defaults(temp_dir):
95101
"Security",
96102
]
97103
assert config.changelog == "CHANGELOG.rst"
98-
assert config.insert_marker == "scriv-insert-here"
104+
assert config.start_marker == "scriv-insert-here"
99105
assert config.rst_header_chars == "=-"
100106
assert config.md_header_level == "1"
101107
assert "{{ date.strftime('%Y-%m-%d') }}" in config.entry_title_template
@@ -111,6 +117,7 @@ def test_reading_config(config_text, temp_dir):
111117
assert config.fragment_directory == "changelog.d"
112118
assert config.changelog == "README.md"
113119
assert config.categories == ["New", "Different", "Gone", "Bad"]
120+
assert config.start_marker == "FIRST!"
114121

115122

116123
def test_reading_config_list(temp_dir):
@@ -323,6 +330,7 @@ def test_reading_toml_file(self, config_text, temp_dir):
323330
config = Config.read()
324331
assert config.changelog == "README.md"
325332
assert config.categories == ["New", "Different", "Gone", "Bad"]
333+
assert config.start_marker == "FIRST!"
326334

327335
def test_toml_without_us(self, temp_dir):
328336
(temp_dir / "pyproject.toml").write_text(GENERIC_TOML_CONFIG)

0 commit comments

Comments
 (0)