Skip to content

Commit

Permalink
deploy: 7c84a7c
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Mar 20, 2024
1 parent 7a81f93 commit 61c31b9
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import subprocess
import sys
import time
from collections import defaultdict
from collections.abc import Callable
from collections.abc import Iterator
from contextlib import ExitStack
Expand Down Expand Up @@ -42,6 +43,8 @@
from dipdup.cli import green_echo
from dipdup.cli import red_echo
from dipdup.config import DipDupConfig
from dipdup.project import TEMPLATES
from dipdup.project import answers_from_replay
from dipdup.project import get_default_answers
from dipdup.sys import set_up_logging

Expand Down Expand Up @@ -519,5 +522,83 @@ def markdownlint() -> None:
exit(1)


# FIXME: It's a full-copilot script to fix the changelog once, quickly. Rewrite or remove it.
@main.command('merge-changelog', help='Print changelog grouped by minor versions')
def merge_changelog() -> None:
group_order = (
'Added',
'Fixed',
'Changed',
'Deprecated',
'Removed',
'Performance',
'Security',
'Other',
)

changelog_path = Path('CHANGELOG.md')
changelog = changelog_path.read_text().split('<!-- Links -->')[0].strip()

changelog_tree: defaultdict[str, defaultdict[str, list[str]]] = defaultdict(lambda: defaultdict(list))
curr_version, curr_group = '', ''

for line in changelog.split('\n'):
line = line.strip()

if line.startswith('## '):
curr_version = line.split('[', 1)[1].split(']')[0]
curr_version = '.'.join(curr_version.split('.')[:2])
elif line.startswith('### '):
curr_group = line[4:]
elif line.startswith('- '):
changelog_tree[curr_version][curr_group].append(line)

for version in sorted(changelog_tree.keys()):
if not version.startswith('7.'):
continue

print(f'## {version}\n')
for group in group_order:
if not changelog_tree[version][group]:
continue

print(f'### {group}\n')
for line in sorted(changelog_tree[version][group]):
print(line)
print()


@main.command('dump-demos', help='Dump Markdown table of available demo projects')
def dump_demos() -> None:
green_echo('=> Dumping demos table')
lines: list[str] = []
demos: list[tuple[str, str, str]] = []

replays = Path('src/dipdup/projects').glob('**/replay.yaml')
for replay_path in replays:
replay = answers_from_replay(replay_path)
package, description = replay['package'], replay['description']
if package in TEMPLATES['other']:
network = ''
elif package in TEMPLATES['evm']:
network = 'EVM'
elif package in TEMPLATES['tezos']:
network = 'Tezos'
demos.append((package, network, description))

# NOTE: Sort by blockchain first, then by package name
demos = sorted(demos, key=lambda x: (x[1], x[0]))

lines = [
'<!-- markdownlint-disable first-line-h1 -->',
'| name | network | description |',
'|-|-|-|',
*(f'| {name} | {network} | {description} |' for name, network, description in demos),
'',
]

Path('docs/8.examples/_demos_table.md').write_text('\n'.join(lines))


if __name__ == '__main__':
main()

0 comments on commit 61c31b9

Please sign in to comment.