Skip to content

Commit 293edc1

Browse files
committed
Merge branch 'master' into fix/keyboardAvoidingPortal
2 parents 3eac3c1 + 14aa457 commit 293edc1

File tree

82 files changed

+2062
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2062
-296
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
jd: 'readonly',
1717
qa: 'readonly',
1818
dd: 'readonly',
19+
ks: 'readonly',
1920
Component: 'readonly',
2021
Page: 'readonly',
2122
App: 'readonly',

analyze_git_stats.py

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import subprocess
2+
import sys
3+
import argparse
4+
from collections import defaultdict
5+
from datetime import datetime
6+
7+
def analyze_git_stats():
8+
# Parse command line arguments
9+
parser = argparse.ArgumentParser(description='Analyze git contribution stats.')
10+
parser.add_argument('--since', type=str, default="1 year ago",
11+
help='Start time period to analyze (e.g. "1 year ago", "2023-01-01")')
12+
parser.add_argument('--until', type=str, default=None,
13+
help='End time period to analyze (e.g. "now", "1 month ago", "2024-01-01"). Defaults to now.')
14+
args = parser.parse_args()
15+
16+
# Configuration
17+
since_date = args.since
18+
until_date = args.until
19+
20+
# Author Alias Mapping
21+
# Format: 'Alias Name': 'Canonical Name'
22+
AUTHOR_MAPPINGS = {
23+
'wangshunnn': 'Soon Wang',
24+
'mackwang112': 'mackwang',
25+
'wangxiaokou': 'wangcuijuan',
26+
'dongxingxingdong': 'WX-DongXing',
27+
'yandadaFreedom': 'lareinayanyu'
28+
# Add more mappings here as needed
29+
}
30+
31+
# Using 'git log' to get the data
32+
# --numstat: shows added/deleted lines
33+
# --no-merges: optional, generally we want to count actual code contributions, not merge commits
34+
# --pretty=format:"AUTHOR:%aN": helps us identify who made the commit
35+
cmd = [
36+
"git", "log",
37+
f"--since={since_date}",
38+
"--numstat",
39+
"--pretty=format:AUTHOR:%aN",
40+
"--no-merges"
41+
]
42+
43+
if until_date:
44+
cmd.append(f"--until={until_date}")
45+
46+
try:
47+
# Run the command with utf-8 encoding errors ignored to prevent crashing on binary filenames or weird author names
48+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, errors='replace')
49+
stdout, stderr = process.communicate()
50+
51+
if process.returncode != 0:
52+
print(f"Error executing git command: {stderr}")
53+
return
54+
55+
except FileNotFoundError:
56+
print("Error: 'git' command not found. Please ensure git is installed.")
57+
return
58+
59+
# Data structure:
60+
# stats = {
61+
# author: {
62+
# 'total': {'added': 0, 'deleted': 0, 'commits': 0},
63+
# 'lt_1000': {'added': 0, 'deleted': 0, 'commits': 0},
64+
# 'lt_5000': {'added': 0, 'deleted': 0, 'commits': 0}
65+
# }
66+
# }
67+
stats = defaultdict(lambda: {
68+
'total': {'added': 0, 'deleted': 0, 'commits': 0},
69+
'lt_1000': {'added': 0, 'deleted': 0, 'commits': 0},
70+
'lt_5000': {'added': 0, 'deleted': 0, 'commits': 0}
71+
})
72+
73+
lines = stdout.split('\n')
74+
75+
pending_author = None
76+
pending_commit_stats = {'added': 0, 'deleted': 0}
77+
78+
def finalize_commit(author, commit_stats):
79+
if not author:
80+
return
81+
82+
added = commit_stats['added']
83+
deleted = commit_stats['deleted']
84+
total_change = added + deleted
85+
86+
# Add to Total
87+
stats[author]['total']['added'] += added
88+
stats[author]['total']['deleted'] += deleted
89+
stats[author]['total']['commits'] += 1
90+
91+
# Add to < 5000
92+
if total_change < 5000:
93+
stats[author]['lt_5000']['added'] += added
94+
stats[author]['lt_5000']['deleted'] += deleted
95+
stats[author]['lt_5000']['commits'] += 1
96+
97+
# Add to < 1000
98+
if total_change < 1000:
99+
stats[author]['lt_1000']['added'] += added
100+
stats[author]['lt_1000']['deleted'] += deleted
101+
stats[author]['lt_1000']['commits'] += 1
102+
103+
for line in lines:
104+
line = line.strip()
105+
if not line:
106+
continue
107+
108+
if line.startswith("AUTHOR:"):
109+
# Finish previous commit
110+
finalize_commit(pending_author, pending_commit_stats)
111+
112+
# Start new commit
113+
raw_author = line.split("AUTHOR:", 1)[1].strip()
114+
pending_author = AUTHOR_MAPPINGS.get(raw_author, raw_author)
115+
pending_commit_stats = {'added': 0, 'deleted': 0}
116+
else:
117+
# It's a numstat line: "added deleted filepath"
118+
parts = line.split(maxsplit=2)
119+
if len(parts) == 3:
120+
added, deleted, _ = parts
121+
122+
# Handle binary files or other non-numeric entries
123+
if added == '-' or deleted == '-':
124+
continue
125+
126+
try:
127+
pending_commit_stats['added'] += int(added)
128+
pending_commit_stats['deleted'] += int(deleted)
129+
except ValueError:
130+
continue
131+
132+
# Finalize the last commit
133+
finalize_commit(pending_author, pending_commit_stats)
134+
135+
# Output formatting
136+
def print_table(title, key_type):
137+
print(f"\n{title}")
138+
print(f"{'Author':<30} | {'Added':<10} | {'Deleted':<10} | {'Total Lines':<12} | {'Commits':<8}")
139+
print("-" * 80)
140+
141+
# Convert to list for sorting
142+
results = []
143+
for author, data in stats.items():
144+
category_data = data[key_type]
145+
total_changed = category_data['added'] + category_data['deleted']
146+
# Only include if they have commits in this category
147+
if category_data['commits'] > 0:
148+
results.append({
149+
'author': author,
150+
'added': category_data['added'],
151+
'deleted': category_data['deleted'],
152+
'total': total_changed,
153+
'commits': category_data['commits']
154+
})
155+
156+
# Sort by total lines changed (descending)
157+
results.sort(key=lambda x: x['total'], reverse=True)
158+
159+
total_added_all = 0
160+
total_deleted_all = 0
161+
total_commits_all = 0
162+
163+
for r in results:
164+
print(f"{r['author']:<30} | {r['added']:<10} | {r['deleted']:<10} | {r['total']:<12} | {r['commits']:<8}")
165+
total_added_all += r['added']
166+
total_deleted_all += r['deleted']
167+
total_commits_all += r['commits']
168+
169+
print("-" * 80)
170+
print(f"{'TOTAL':<30} | {total_added_all:<10} | {total_deleted_all:<10} | {total_added_all+total_deleted_all:<12} | {total_commits_all:<8}")
171+
172+
print_table("=== ALL COMMITS ===", 'total')
173+
print_table("=== COMMITS < 5000 LINES ===", 'lt_5000')
174+
print_table("=== COMMITS < 1000 LINES ===", 'lt_1000')
175+
176+
if __name__ == "__main__":
177+
analyze_git_stats()

docs-vitepress/.vitepress/config.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@ declare module "vitepress" {
2020
}
2121
}
2222
}
23+
interface ExtendedSidebarItem extends DefaultTheme.SidebarItem {
24+
badge?: { text?: string }
25+
items?: ExtendedSidebarItem[]
26+
}
27+
type ExtendedSidebar =
28+
| ExtendedSidebarItem[]
29+
| {
30+
[path: string]:
31+
| ExtendedSidebarItem[]
32+
| { items: ExtendedSidebarItem[]; base: string }
33+
}
2334

2435
const ogUrl = "https://mpxjs.cn/"
2536
const ogImage = `${ogUrl}logo.png`
2637
const title = "Mpx 框架"
2738
const description = "深度性能优化的增强型小程序开发框架"
2839

29-
const sidebar: DefaultTheme.Sidebar = {
40+
const sidebar: ExtendedSidebar = {
3041
"/guide/": [
3142
{
3243
text: "基础",
@@ -94,11 +105,12 @@ const sidebar: DefaultTheme.Sidebar = {
94105
text: "跨端基础",
95106
items: [
96107
{ text: "跨端输出配置", link: "/guide/cross-platform/basic" },
97-
{ text: "条件编译机制", link: "/guide/cross-platform/conditional" }
108+
{ text: "条件编译机制", link: "/guide/cross-platform/conditional" },
98109
],
99110
},
100111
{
101112
text: "跨端 RN",
113+
badge: { text: "新" },
102114
items: [
103115
{ text: "快速开始", link: "/guide/rn/start" },
104116
{ text: "组件使用与开发", link: "/guide/rn/component" },
@@ -1013,7 +1025,7 @@ export default withPwa(
10131025
level: [2, 3],
10141026
label: "本页目录",
10151027
},
1016-
sidebar,
1028+
sidebar: sidebar as DefaultTheme.Sidebar,
10171029
darkModeSwitchLabel: "外观",
10181030
sidebarMenuLabel: "菜单",
10191031
returnToTopLabel: "返回顶部",
@@ -1038,13 +1050,15 @@ export default withPwa(
10381050
vite: {
10391051
logLevel: "info",
10401052
plugins: [
1053+
// @ts-ignore
10411054
llmstxt({
10421055
customTemplateVariables: {
10431056
title,
10441057
description,
10451058
},
10461059
ignoreFiles: ["index.md", "api/index.md"],
10471060
}),
1061+
// @ts-ignore
10481062
groupIconVitePlugin({
10491063
customIcon: {
10501064
ios: "logos:apple",
@@ -1085,6 +1099,15 @@ export default withPwa(
10851099
)
10861100
),
10871101
},
1102+
{
1103+
find: /^.*\/VPSidebarItem\.vue$/,
1104+
replacement: fileURLToPath(
1105+
new URL(
1106+
"./theme/alias-components/CustomSidebarItem.vue",
1107+
import.meta.url
1108+
)
1109+
),
1110+
},
10881111
],
10891112
},
10901113
},

docs-vitepress/.vitepress/theme/alias-components/CustomMenuLink.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts" setup>
22
import type { DefaultTheme } from 'vitepress/theme'
33
import { useData } from 'vitepress'
4+
// @ts-ignore
45
import { isActive } from 'vitepress/dist/client/shared.js'
56
import { VPLink } from 'vitepress/theme'
67

docs-vitepress/.vitepress/theme/alias-components/CustomNavBarMenuLink.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts" setup>
22
import type { DefaultTheme } from 'vitepress/theme'
33
import { useData } from 'vitepress'
4+
// @ts-ignore
45
import { isActive } from 'vitepress/dist/client/shared.js'
56
import { VPLink } from 'vitepress/theme'
67

0 commit comments

Comments
 (0)