Skip to content

Commit

Permalink
DRIVERS-2789 Convert Auth Spec to Markdown (#1501)
Browse files Browse the repository at this point in the history
* DRIVERS-2789 Convert Auth Spec to Markdown
  • Loading branch information
blink1073 authored Feb 7, 2024
1 parent 3b8e7e4 commit a5e5641
Show file tree
Hide file tree
Showing 19 changed files with 2,674 additions and 2,360 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ repos:
rev: 0.7.17
hooks:
- id: mdformat
args: ["--wrap=120"]
args: ["--wrap=120", "--number"]
additional_dependencies:
[mdformat-gfm]
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]

- repo: https://github.com/tcort/markdown-link-check
rev: v3.11.2
Expand Down
10 changes: 5 additions & 5 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
"License Elements" means the following high-level license attributes as selected by Licensor and indicated in the
title of this License: Attribution, Noncommercial, ShareAlike.

1. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use,
2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use,
first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other
applicable laws.

1. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide,
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide,
royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights
in the Work as stated below:

Expand Down Expand Up @@ -144,7 +144,7 @@ forth in Sections 4(e) and 4(f).
public digital performance is primarily intended for or directed toward commercial advantage or private monetary
compensation.

1. Representations, Warranties and Disclaimer
5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND ONLY TO THE EXTENT OF
ANY RIGHTS HELD IN THE LICENSED WORK BY THE LICENSOR. THE LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND
Expand All @@ -157,7 +157,7 @@ THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS
LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

1. Termination
7. Termination

a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of
this License. Individuals or entities who have received Derivative Works (as defined in Section 1 above) or
Expand All @@ -170,7 +170,7 @@ THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
been, or is required to be, granted under the terms of this License), and this License will continue in full force
and effect unless terminated as stated above.

1. Miscellaneous
8. Miscellaneous

a. Each time You distribute or publicly digitally perform the Work (as defined in Section 1 above) or a Collective
Work (as defined in Section 1 above), the Licensor offers to the recipient a license to the Work on the same terms
Expand Down
3 changes: 3 additions & 0 deletions markdown_link_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"ignorePatterns": [
{
"pattern": "^/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#"
},
{
"pattern": "^https://github.com/10gen/mongo-enterprise-modules"
}
]
}
17 changes: 12 additions & 5 deletions scripts/migrate_to_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@
# (https://github.com/mongodb/specifications/blob/master/source/...)
# and rewrite them to use appropriate md links.
# If the link is malformed we ignore and print an error.
rel_pattern = re.compile(f'(\.\.\S*/{path.name})')
md_pattern = re.compile(f'(\(http\S*/{path.name})')
rst_pattern = re.compile(f'(<http\S*/{path.name})')
abs_pattern = re.compile(f'(/source/\S*/{path.name})')
target = path.name
curr = path
while curr.parent.name != 'source':
target = f'{curr.parent.name}/{target}'
curr = curr.parent
suffix = f'\S*/{target}'
rel_pattern = re.compile(f'(\.\.{suffix})')
md_pattern = re.compile(f'(\(http{suffix})')
rst_pattern = re.compile(f'(<http{suffix})')
abs_pattern = re.compile(f'(/source{suffix})')
for p in Path("source").rglob("*"):
if p.suffix not in ['.rst', '.md']:
continue
Expand Down Expand Up @@ -127,12 +133,13 @@

if new_line != line:
found = True
print(new_line)
new_lines.append(new_line)

if found:
with p.open('w') as fid:
fid.writelines(new_lines)
print(f'Update link(s) in {p}')
print(f'Updated link(s) in {p}')


print('Created markdown file:')
Expand Down
Loading

0 comments on commit a5e5641

Please sign in to comment.