Skip to content

Commit

Permalink
Merge pull request #22 from Tencent/auto_md
Browse files Browse the repository at this point in the history
Auto md
  • Loading branch information
Luozf12345 authored Jan 5, 2024
2 parents 7d8d689 + 09b02bb commit a2f7d02
Show file tree
Hide file tree
Showing 45 changed files with 1,583 additions and 4,043 deletions.
Binary file modified tdesign-component/demo_tool/bin/demo_tool
Binary file not shown.
2 changes: 1 addition & 1 deletion tdesign-component/demo_tool/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.0
3.10.0
1 change: 1 addition & 0 deletions tdesign-component/example/assets/api/avatar_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
| avatarDisplayWidget | Widget? | - | 带操作头像自定义操作Widget |
| avatarDisplayBorder | double | 2 | 带操作\展示的头像描边宽度 |
| avatarDisplayListAsset | List<String>? | - | 带操作\展示的头像列表 (本地资源) |
| backgroundColor | Color? | - | 自定义文案时背景色 |
1 change: 1 addition & 0 deletions tdesign-component/example/assets/api/tab-bar_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
| dividerColor | Color? | - | 分割线颜色(可选) |
| showTopBorder | bool? | true | 是否展示bar上边线(设置为true 但是topBorder样式未设置,则使用默认值,非胶囊型才生效) |
| topBorder | BorderSide? | - | 上边线样式 |
| useSafeArea | bool | true | 使用安全区域 |

```
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
child: Column(
children: [
Container(
color: showBorder ? Colors.green : Colors.transparent,
color: showBorder ? TDTheme.of(context).brandDisabledColor : Colors.transparent,
child: Icon(iconData),
),
TDText(iconData.name)
Expand Down
2 changes: 0 additions & 2 deletions tdesign-component/example/assets/code/image._imageClip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
child: const TDImage(
assetUrl: 'assets/img/image.png',
type: TDImageType.fitHeight,
width: 89,
height: 72,
),
),
],
Expand Down
35 changes: 35 additions & 0 deletions tdesign-component/example/assets/code/image._imageFitWidth.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

Widget _imageFitWidth(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 24),
child: Row(
children: [
const SizedBox(
width: 16,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 16),
child: TDText(
'适应宽',
font: TDTheme.of(context).fontBodyMedium,
textColor: TDTheme.of(context).fontGyColor2.withOpacity(0.6),
),
),
Container(
width: 72,
height: 89,
color: Colors.black,
child: const TDImage(
assetUrl: 'assets/img/image.png',
type: TDImageType.fitWidth,
),
),
],
),
],
),
);
}
6 changes: 1 addition & 5 deletions tdesign-component/example/assets/code/loading._buildRow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
Widget _buildRow(List<Widget> list) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: list.fold(
[],
(previousValue, element) =>
[...previousValue, element, rowSpace])));
child: Row(children: list.fold([], (previousValue, element) => [...previousValue, element, rowSpace])));
}
28 changes: 16 additions & 12 deletions tdesign-component/example/assets/code/slider._buildCapsule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return Column(
children: [
TDSlider(
sliderThemeData: TDSliderThemeFactory.capsuleThemeData.copyWith(
sliderThemeData: TDSliderThemeData.capsule(
min: 0,
max: 100,
scaleFormatter: (value) => value.toInt().toString(),
Expand All @@ -16,7 +16,7 @@
height: 16,
),
TDRangeSlider(
sliderThemeData: TDSliderThemeFactory.capsuleThemeData.copyWith(
sliderThemeData: TDSliderThemeData.capsule(
min: 0,
max: 100,
scaleFormatter: (value) => value.toInt().toString(),
Expand All @@ -29,7 +29,7 @@
height: 16,
),
TDSlider(
sliderThemeData: TDSliderThemeFactory.capsuleThemeData.copyWith(
sliderThemeData: TDSliderThemeData.capsule(
min: 0,
max: 100,
scaleFormatter: (value) => value.toInt().toString(),
Expand All @@ -44,7 +44,7 @@
height: 16,
),
TDRangeSlider(
sliderThemeData: TDSliderThemeFactory.capsuleThemeData.copyWith(
sliderThemeData: TDSliderThemeData.capsule(
min: 0,
max: 100,
showThumbValue: true,
Expand All @@ -60,15 +60,16 @@
height: 16,
),
TDSlider(
sliderThemeData: TDSliderThemeFactory.capsuleThemeData.copyWith(
activeTickMarkColor: const Color(0xFFE7E7E7),
inactiveTickMarkColor: const Color(0xFFE7E7E7),
sliderThemeData: TDSliderThemeData.capsule(
showScaleValue: true,
divisions: 5,
min: 0,
max: 100,
scaleFormatter: (value) => value.toInt().toString(),
),
)..updateSliderThemeData((data) => data.copyWith(
activeTickMarkColor: const Color(0xFFE7E7E7),
inactiveTickMarkColor: const Color(0xFFE7E7E7),
)),
value: 60,
// divisions: 5,
onChanged: (value) {},
Expand All @@ -77,15 +78,18 @@
height: 16,
),
TDRangeSlider(
sliderThemeData: TDSliderThemeFactory.capsuleThemeData.copyWith(
activeTickMarkColor: const Color(0xFFE7E7E7),
inactiveTickMarkColor: const Color(0xFFE7E7E7),
sliderThemeData: TDSliderThemeData.capsule(
showScaleValue: true,
divisions: 5,
min: 0,
max: 100,
scaleFormatter: (value) => value.toInt().toString(),
),
)
..updateSliderThemeData((data) =>
data.copyWith(
activeTickMarkColor: const Color(0xFFE7E7E7),
inactiveTickMarkColor: const Color(0xFFE7E7E7),
)),
value: const RangeValues(20, 60),
// divisions: 5,
onChanged: (value) {},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

Widget _buildVerticalDotsBarSwiper(BuildContext context) {
return Swiper(
autoplay: true,
itemCount: 6,
loop: true,
scrollDirection:Axis.vertical,
pagination: const SwiperPagination(
alignment: Alignment.bottomRight,
builder: TDSwiperPagination.dotsBar),
itemBuilder: (BuildContext context, int index) {
return const TDImage(assetUrl: 'assets/img/image.png',);
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
exampleTxt,
font: TDTheme.of(context).fontHeadlineLarge,
textColor: TDTheme.of(context).brandNormalColor,
backgroundColor: TDTheme.of(context).successHoverColor,
backgroundColor: TDTheme.of(context).brandFocusColor,
);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Widget _buildVerticalCenterText(BuildContext context) {
return const TDText(
return TDText(
'中华人民共和国腾讯科技',
// font: Font(size: 100, lineHeight: 100),
forceVerticalCenter: true,
backgroundColor: Colors.orange,
backgroundColor: TDTheme.of(context).brandHoverColor,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Widget _getSystemText(BuildContext context) {
return TDText(
exampleTxt,
backgroundColor: TDTheme.of(context).successHoverColor,
backgroundColor: TDTheme.of(context).brandHoverColor,
).getRawText(context: context);
}
59 changes: 39 additions & 20 deletions tdesign-component/example/lib/base/example_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,30 @@ class _ExamplePageState extends State<ExamplePage> {
return WebMdTool.needGenerateWebMd
? Container(
margin: const EdgeInsets.only(top: 24),
child: TDButton(
text: '生成Web使用md',
type: TDButtonType.fill,
onTap: () => WebMdTool.generateWebMd(
model: model,
description: widget.desc,
exampleCodeGroup:
child: Column(
children: [
TDButton(
text: '生成Web使用md',
type: TDButtonType.fill,
onTap: () => WebMdTool.generateWebMd(
model: model,
description: widget.desc,
exampleCodeGroup:
widget.exampleCodeGroup,
exampleModuleList:
exampleModuleList:
widget.children,
testList: widget.test,
singleChild:
testList: widget.test,
singleChild:
widget.showSingleChild
? widget.singleChild
: null),
),
TDButton(
text: '返回首页',
type: TDButtonType.fill,
onTap: () => Navigator.of(context).maybePop(),
),
],
),
)
: Container();
Expand Down Expand Up @@ -163,17 +172,26 @@ class _ExamplePageState extends State<ExamplePage> {
left: 16,
right: 16,
bottom: 0,
child: TDButton(
text: '生成Web使用md',
type: TDButtonType.fill,
onTap: () => WebMdTool.generateWebMd(
model: model,
description: widget.desc,
exampleCodeGroup: widget.exampleCodeGroup,
exampleModuleList: widget.children,
testList: widget.test,
singleChild:
child: Column(
children: [
TDButton(
text: '生成Web使用md',
type: TDButtonType.fill,
onTap: () => WebMdTool.generateWebMd(
model: model,
description: widget.desc,
exampleCodeGroup: widget.exampleCodeGroup,
exampleModuleList: widget.children,
testList: widget.test,
singleChild:
widget.showSingleChild ? widget.singleChild : null),
),
TDButton(
text: '返回首页',
type: TDButtonType.fill,
onTap: () => Navigator.of(context).maybePop(),
),
],
)),
],
),
Expand Down Expand Up @@ -233,6 +251,7 @@ class _ExamplePageState extends State<ExamplePage> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(WebMdTool.needGenerateWebMd) const TDText('WebGenTag'),
TDText(
widget.title,
font: TDTheme.of(context).fontHeadlineSmall,
Expand Down
19 changes: 16 additions & 3 deletions tdesign-component/example/lib/base/web_md_tool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class WebMdTool {
WebMdTool._();

/// 用于生成web端的md,正常使用不要开启
static const bool needGenerateWebMd = false;
static bool needGenerateWebMd = false;

/// 生成web端的md
static void generateWebMd({
Expand Down Expand Up @@ -48,7 +48,20 @@ class WebMdTool {
}
var mdContent = _getTemplate(model.text, description,
model.spline ?? 'other', exampleCodeSb.toString(), api.toString());
var file = File('/sdcard/td/web_md/${model.name}/README.md');
print('生成演示代码成功:\n${mdContent.substring(0,50)}...');

var path = "";
if(Platform.environment['FLUTTER_TEST'] == 'true'){

// file:///Users/zflyluo/WorkSpace/flutter/tdesign_group/tdesign-mobile-flutter/tdesign-component/example/main.dart
var baseDir = Platform.script.toFilePath().split('/tdesign-component')[0];
path = '$baseDir/tdesign-site/src/${model.name}/README.md';
// path = '$baseDir/test/src/${model.name}/README.md';
// File
} else {
path = '/sdcard/td/web_md/${model.name}/README.md';
}
var file = File(path);
if (!file.existsSync()) {
file.createSync(recursive: true);
}
Expand All @@ -65,7 +78,7 @@ class WebMdTool {
list.forEach((element) {
exampleCodeSb.writeln('');
exampleCodeSb.writeln('''
<td-code-block panel="Dart">
<pre slot="Dart" lang="javascript">${element}</pre>
Expand Down
Loading

0 comments on commit a2f7d02

Please sign in to comment.