summaryrefslogtreecommitdiff
path: root/fix_links.py
blob: bfb3c5fb707de91fe7920183a2609161b23b3e31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import os
import re
import sys


removed = {
    "aiomysql",
    "aiosqlite",
    "associationproxy_toplevel",
    "asyncio_events_run_async",
    "asyncio_inspector",
    "asyncio_install",
    "asyncio_orm_avoid_lazyloads",
    "asyncio_scoped_session",
    "asyncio_toplevel",
    "asyncmy",
    "asyncpg_prepared_statement_cache",
    "asyncpg_prepared_statement_name",
    "automap_by_module",
    "automap_intercepting_columns",
    "automap_toplevel",
    "azure_synapse_ignore_no_transaction_on_rollback",
    "baked_in",
    "baked_toplevel",
    "baked_with_before_compile",
    "change_3907",
    "change_3953",
    "change_4109",
    "composite_association_proxy",
    "composite_operations",
    "context_default_functions",
    "core_inspection_toplevel",
    "custom_version_counter",
    "cx_oracle_setinputsizes",
    "dataclasses_pydantic",
    "declarative_inheritance",
    "declarative_many_to_many",
    "declarative_mixins",
    "declarative_relationship_eval",
    "declarative_table_args",
    "declarative_toplevel",
    "defaults_client_invoked_sql",
    "defaults_sequences",
    "dialect-postgresql-asyncpg",
    "dynamic_relationship",
    "examples_adjacencylist",
    "examples_asyncio",
    "examples_caching",
    "examples_inheritance",
    "examples_instrumentation",
    "examples_performance",
    "examples_session_orm_events",
    "examples_sharding",
    "examples_toplevel",
    "examples_versioned_history",
    "examples_versioned_rows",
    "examples_versioning",
    "feature_joins_09",
    "generic_functions",
    "horizontal_sharding_toplevel",
    "hybrid_pep484_naming",
    "hybrids_toplevel",
    "inspection_toplevel",
    "legacy_is_orphan_addition",
    "mapper_column_property_sql_expressions",
    "mapper_column_property_sql_expressions_composed",
    "mapper_composite",
    "mapper_sql_expressions",
    "mapper_version_counter",
    "mapping_columns_toplevel",
    "metadata_defaults",
    "metadata_defaults_toplevel",
    "metadata_reflection",
    "metadata_reflection_dbagnostic_types",
    "metadata_reflection_schemas",
    "metadata_reflection_toplevel",
    "migration_2992",
    "migration_3061",
    "mssql_comment_support",
    "mssql_identity",
    "mssql_indexes",
    "mssql_insert_behavior",
    "mssql_isolation_level",
    "mssql_pyodbc_access_tokens",
    "mssql_pyodbc_fastexecutemany",
    "mssql_pyodbc_setinputsizes",
    "mssql_reset_on_return",
    "mssql_toplevel",
    "mssql_triggers",
    "multipart_schema_names",
    "mutable_toplevel",
    "mypy_declarative_mixins",
    "mypy_toplevel",
    "mysql_indexes",
    "mysql_insert_on_duplicate_key_update",
    "mysql_isolation_level",
    "mysql_sql_mode",
    "mysql_storage_engines",
    "mysql_timestamp_onupdate",
    "mysql_toplevel",
    "oracledb",
    "oracle_isolation_level",
    "oracle_max_identifier_lengths",
    "oracle_toplevel",
    "orm_declarative_dataclasses",
    "orm_declarative_dataclasses_declarative_table",
    "orm_declarative_dataclasses_mixin",
    "orm_declarative_dc_mixins",
    "orm_declarative_native_dataclasses",
    "orm_declarative_native_dataclasses_non_mapped_fields",
    "orm_imperative_dataclasses",
    "postgresql_alternate_search_path",
    "postgresql_column_valued",
    "postgresql_constraint_options",
    "postgresql_indexes",
    "postgresql_insert_on_conflict",
    "postgresql_isolation_level",
    "postgresql_match",
    "postgresql_operator_classes",
    "postgresql_psycopg",
    "postgresql_readonly_deferrable",
    "postgresql_reset_on_return",
    "postgresql_simple_match",
    "postgresql_table_valued",
    "postgresql_table_valued_overview",
    "proxying_dictionaries",
    "psycopg2_executemany_mode",
    "pysqlcipher",
    "pysqlite_regexp",
    "pysqlite_serializable",
    "pysqlite_serializable                         ",
    "pysqlite_threading_pooling",
    "reflection_overriding_columns",
    "relationships_backref",
    "server_defaults",
    "server_side_version_counter",
    "session_expire",
    "session_object_states",
    "session_referencing_behavior",
    "sqlite_autoincrement",
    "sqlite_foreign_keys",
    "sqlite_include_internal",
    "sqlite_isolation_level",
    "sqlite_on_conflict_ddl",
    "sqlite_on_conflict_insert",
    "sqlite_toplevel",
    "triggered_columns",
    "unitofwork_contextual",
    "unitofwork_merging",
    "write_only_relationship",
}


def fixlink(m):
    print(f"MATCH: {m}")
    if m.group(1) in removed:
        return f"ref_{m.group(1)}"
    else:
        return m.group(0)


def fix(path):
    print(f"path: {path}")
    with open(path) as file_:
        text = file_.read()
        text = re.sub(r":ref:`.+ <(.+?)>`", fixlink, text)
        print("NEXT PASS")
        text = re.sub(r":ref:`(.*?)`", fixlink, text)

    with open(path, "w") as file_:
        file_.write(text)


for root, dir_, files in os.walk(sys.argv[1]):
    for file_ in files:
        if ".venv" in root:
            continue
        if file_.endswith(".rst") or file_.endswith(".py"):
            path = os.path.join(root, file_)
            fix(path)