-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: track deprecations in release notes
* add script doc/mf6io/mf6ivar/deprecations.py to scrape DFNs and generate markdown table * run deprecations script in docs.yml CI and upload result file as artifact * add deprecations page to ReadTheDocs * add mk_deprecations.py script to convert markdown deprecations to LaTeX table * include deprecations in release notes * add deprecation policy section to DEVELOPER.md
- Loading branch information
Showing
12 changed files
with
405 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# This script converts the markdown deprecations table | ||
# into a latex table for inclusion in the release notes | ||
import argparse | ||
from pathlib import Path | ||
from warnings import warn | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("path") | ||
args = parser.parse_args() | ||
|
||
header = r""" | ||
\section{Deprecations} | ||
Deprecated/removed options in the current version of MODFLOW 6. Deprecated options are not suggested for use and may (but need not) be removed in a future version of MODFLOW 6. Removed options are no longer available in the current version of MODFLOW 6. | ||
\small | ||
\begin{longtable}[!htbp]{p{5cm} p{3cm} p{3cm} p{1.5cm}} | ||
\caption{List of deprecations and removals} | ||
\label{table:deprecations} | ||
\tabularnewline | ||
\hline | ||
\hline | ||
\textbf{File} & \textbf{Option} & \textbf{Deprecated} & \textbf{Removed} \\ | ||
\hline | ||
\endfirsthead | ||
\hline | ||
\hline | ||
\textbf{File} & \textbf{Option} & \textbf{Deprecated} & \textbf{Removed} \\ | ||
\hline | ||
\endhead | ||
""" | ||
|
||
footer = r""" | ||
\hline | ||
\end{longtable} | ||
\normalsize | ||
""" | ||
|
||
fname = "deprecations" | ||
fpath = Path(args.path).expanduser().absolute() | ||
fnametex = Path(f"{fname}.tex").absolute() | ||
fnametex.unlink(missing_ok=True) | ||
|
||
# if the markdown file exists, convert it to latex | ||
if fpath.is_file(): | ||
ftex = open(fnametex, 'w') | ||
ftex.write(header) | ||
skipline = True | ||
with open(fpath) as fmd: | ||
for line in fmd: | ||
if not skipline: | ||
ll = line.strip().split('|') | ||
ll = ll[1:-1] | ||
linetex = "& ".join(ll) | ||
linetex = linetex.replace("\\", "/") | ||
linetex += '\\\\' + '\n' | ||
linetex = linetex.replace("%", "\\%") | ||
linetex = linetex.replace("_", "\\_") | ||
ftex.write(linetex) | ||
ftex.write("\\hline\n") | ||
if ":-" in line: | ||
skipline = False | ||
ftex.write(footer) | ||
ftex.close() | ||
print(f"Created LaTex file {fnametex} from markdown deprecations file {fpath}") | ||
else: | ||
warn(f"Deprecations not found: {fpath}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
from typing import List, Tuple, Optional | ||
from packaging.version import Version | ||
from pathlib import Path | ||
|
||
|
||
def get_deprecations(dfndir) -> List[Tuple[Path, str, Version, Optional[Version]]]: | ||
dfns = Path(dfndir).rglob("*.dfn") | ||
deps = {} | ||
for dfn in dfns: | ||
with open(dfn, "r") as f: | ||
name = None | ||
for line in f: | ||
if line.startswith("#"): | ||
continue | ||
keys = ["deprecated", "removed"] | ||
ikeys = {k: i for i, k in enumerate(keys)} | ||
for key in keys: | ||
if line.startswith("name"): | ||
name = line.split()[1] | ||
if line.startswith(key): | ||
val = deps.get((dfn, key), [None, None]) | ||
key, ver = line.split() | ||
ik = ikeys[key] | ||
val[ik] = val[ik] if val[ik] else Version(ver) | ||
deps[(dfn, name)] = val | ||
|
||
return [(file, key, dep, rem) for (file, key), (dep, rem) in deps.items()] | ||
|
||
|
||
def create_deprecations_file(dfndir, mddir, verbose): | ||
deprecations = get_deprecations(dfndir) | ||
deps_path = (Path(mddir) / 'deprecations.md').absolute() | ||
if verbose: | ||
print(f"Found {len(deprecations)} deprecations, writing {deps_path}") | ||
with open(deps_path, "w") as f: | ||
s = "#### Deprecations\n\n" | ||
s += "The following table lists deprecated options and the versions in which they were deprecated and (optionally) removed.\n\n" | ||
if any(deprecations): | ||
s += "| Model-Package | Option | Deprecated | Removed |\n" | ||
s += "|:--------------|:-------|:-----------|:--------|\n" | ||
for (file, option, deprecated, removed) in deprecations: | ||
s += f"| {file.stem} | {option} | {deprecated} | {removed if removed else ''} |\n" | ||
if len(s) > 0: | ||
s += "\n" | ||
f.write(s) | ||
|
||
|
||
if __name__ == '__main__': | ||
dfndir = os.path.join('.', 'dfn') | ||
mddir = os.path.join('.', 'md') | ||
create_deprecations_file(dfndir, mddir, verbose=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#### Deprecations | ||
|
||
The following table lists deprecated options and the versions in which they were deprecated and (optionally) removed. | ||
|
||
| Model-Package | Option | Deprecated | Removed | | ||
|:--------------|:-------|:-----------|:--------| | ||
| gwf-mvr | unit_conversion | 6.4.2 | | | ||
| gwf-mvr | csv_output_filerecord | 6.1.1 | | | ||
| gwf-mvr | csv_output | 6.1.1 | | | ||
| gwf-mvr | csvfile | 6.1.1 | | | ||
| gwf-mvr | outer_hclose | 6.1.1 | | | ||
| gwf-mvr | outer_rclosebnd | 6.1.1 | | | ||
| gwf-mvr | inner_hclose | 6.1.1 | | | ||
|
Oops, something went wrong.