Skip to content

Commit

Permalink
update script to handle absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Jan 31, 2024
1 parent 5226ea6 commit 9c162fd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions scripts/migrate_to_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,25 @@
target = f"{curr.parent.name}/{target}"
curr = curr.parent
pattern = re.compile(f'(<.*{target}[>#])')
for p in Path("source").rglob("*"):
if not '.rst' in p.name:
continue
pattern2 = re.compile(f'(/source/{target}[>#])')
for p in Path("source").rglob("*.rst"):
found = False
with p.open() as fid:
lines = fid.readlines()
new_lines = []
for line in lines:
match = re.search(pattern, line)
if not match:
match = re.search(pattern2, line)
if match:
found = True
new_name = path.name.replace('.rst', '.md')
line = line.replace(path.name, new_name)
new_lines.append(line)
continue
matchstr = match.groups()[0]
if matchstr[0].startswith('https'):
substr = match.string
if not substr.startswith('<https://github.com/mongodb/specifications/blob/master/source/'):
print('*** Error in link: ', substr, p)
new_lines.append(line)
Expand Down
2 changes: 1 addition & 1 deletion source/connections-survive-step-down/tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ server communication.


.. _CMAP: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst
.. _PoolClearedEvent: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#events
.. _PoolClearedEvent: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.md#events
.. _serverStatus: https://www.mongodb.com/docs/manual/reference/command/serverStatus
.. _connections.totalCreated: https://www.mongodb.com/docs/manual/reference/command/serverStatus/#serverstatus.connections.totalCreated
4 changes: 2 additions & 2 deletions source/server-discovery-and-monitoring/server-monitoring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1251,10 +1251,10 @@ Changelog
.. _SDAM Monitoring spec: server-discovery-and-monitoring-logging-and-monitoring.rst#heartbeats
.. _OP_MSG Spec: /source/message/OP_MSG.rst
.. _OP_MSG exhaustAllowed flag: /source/message/OP_MSG.rst#exhaustAllowed
.. _Connection Pool: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#Connection-Pool
.. _Connection Pool: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.md#Connection-Pool
.. _Why synchronize clearing a server's pool with updating the topology?: server-discovery-and-monitoring.rst#why-synchronize-clearing-a-server-s-pool-with-updating-the-topology?
.. _Client Side Operations Timeout Spec: /source/client-side-operations-timeout/client-side-operations-timeout.rst
.. _timeoutMS: /source/client-side-operations-timeout/client-side-operations-timeout.rst#timeoutMS
.. _Why does the pool need to support closing in use connections as part of its clear logic?: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#Why-does-the-pool-need-to-support-closing-in-use-connections-as-part-of-its-clear-logic?
.. _Why does the pool need to support closing in use connections as part of its clear logic?: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.md#Why-does-the-pool-need-to-support-closing-in-use-connections-as-part-of-its-clear-logic?
.. _DRIVERS-2246: https://jira.mongodb.org/browse/DRIVERS-2246
.. _MongoDB Handshake spec: /source/mongodb-handshake/handshake.rst#client-env
2 changes: 1 addition & 1 deletion source/server-selection/server-selection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ References
.. _Max Staleness: https://github.com/mongodb/specifications/tree/master/source/max-staleness
.. _idleWritePeriodMS: https://github.com/mongodb/specifications/blob/master/source/max-staleness/max-staleness.rst#idlewriteperiodms
.. _Driver Authentication: https://github.com/mongodb/specifications/blob/master/source/auth
.. _maxConnecting: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#connection-pool
.. _maxConnecting: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.md#connection-pool
.. _Connection Monitoring and Pooling: /source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst
.. _Global Command Argument: /source/message/OP_MSG.rst#global-command-arguments

Expand Down
2 changes: 1 addition & 1 deletion source/uri-options/uri-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,5 @@ Changelog

----

.. _Connection Pooling spec: https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#connection-pool-options-1
.. _Connection Pooling spec: https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.md#connection-pool-options-1
.. _SOCKS5 support spec: https://github.com/mongodb/specifications/blob/master/source/socks5-support/socks5.rst#mongoclient-configuration

0 comments on commit 9c162fd

Please sign in to comment.