整理一下readme

This commit is contained in:
estom
2024-01-20 12:11:56 +08:00
parent 13938e0b06
commit b88c50976c
4 changed files with 97 additions and 499 deletions

168
README.md
View File

@@ -1,71 +1,97 @@
# 笔记
## 简介
一个码农的毕生所学。
## 目标
- 考研
- 就业
- 上学
## 目录
### 语言篇
- Android
- C++
- Java
- JavaScript
- Latex
- MATLAB
- NodeJS
- PHP
- Python
-
### 技术篇
- [docker](./docker/1%20简介安装.md)
- git
- Linux
- Maven
- office
- Spark
- Spring
- SVN
### 基础篇
- 编译原理
- 操作系统
- 单片机
- 计算机网络
- 计算机网络实验
- 架构模式
- 软件文档写作
- 设计模式
- 数据结构
- 数据库
- 算法
- UML建模
- Windows程序设计
### 数学篇
- 概率论与数理统计
- 微积分
- 线性代数
- 张量
### 机器学习篇
- 机器学习
- pytorch
- sklearn
- TensorFlow
### 生活
- 毕业设计
- 文献阅读
- Tool
## 参考
欢迎个位,把那些占位符的地方补充完整。
仅供参考,记录一下六年的大学与研究生生涯。
## notes
### 简介
一个码农的毕生所学。
### 语言篇
- [Android](Android/README.md)
- [C++](C++/README.md)
- [CSS](CSS/README.md)
- [Go](Go/README.md)
- [HTML](HTML/README.md)
- [Java](Java/README.md)
- [JavaScript](JavaScript/README.md)
- [NodeJS](NodeJS/README.md)
- [PHP](PHP/README.md)
- [Scala](Scala/README.md)
### 技术篇
- [Bootstrap](Bootstrap/README.md)
- [Git](Git/README.md)
- [Idea](Idea/README.md)
- [JBoss](JBoss/README.md)
- [JDBC](JDBC/README.md)
- [Latex](Latex/README.md)
- [Matlab](Matlab/README.md)
- [MyBatis](MyBatis/README.md)
- [MySQL](MySQL/README.md)
- [Netty](Netty/README.md)
- [Office](Office/README.md)
- [PlantUML](PlantUML/README.md)
- [Postman](Postman/README.md)
- [Python](Python/README.md)
- [Quartz](Quartz/README.md)
- [Redis](Redis/README.md)
- [SVN](SVN/README.md)
- [Spring](Spring/README.md)
- [SpringCloud](SpringCloud/README.md)
- [SpringCloudAlibaba](SpringCloudAlibaba/README.md)
- [SwarmIntelligence](SwarmIntelligence/README.md)
- [TOOL](TOOL/README.md)
- [UML建模](UML建模/README.md)
- [Vscode](Vscode/README.md)
- [Vue](Vue/README.md)
- [blog](blog/README.md)
- [code_segment](code_segment/README.md)
- [docker](docker/README.md)
- [grpc](grpc/README.md)
- [kubenets](kubenets/README.md)
- [mac使用教程](mac使用教程/README.md)
- [maven](maven/README.md)
- [pytorch](pytorch/README.md)
- [windows程序设计](windows程序设计/README.md)
- [加密](加密/README.md)
- [单片机](单片机/README.md)
- [微服务](微服务/README.md)
### 基础篇
- [Linux](Linux/README.md)
- [操作系统](操作系统/README.md)
- [数据库](数据库/README.md)
- [数据结构](数据结构/README.md)
- [文献阅读](文献阅读/README.md)
- [机器学习](机器学习/README.md)
- [架构模式](架构模式/README.md)
- [概率论与数理统计](概率论与数理统计/README.md)
- [算法](算法/README.md)
- [编译原理](编译原理/README.md)
- [计算机网络](计算机网络/README.md)
- [计算机网络实验](计算机网络实验/README.md)
- [设计模式](设计模式/README.md)
- [软件文档写作](软件文档写作/README.md)
### 数学篇
- [微积分](微积分/README.md)
- [线性代数](线性代数/README.md)
### 机器学习篇
- [Sklearn](Sklearn/README.md)
- [Spark](Spark/README.md)
- [Tensorflow](Tensorflow/README.md)
## 生活
生命会流逝,求知不会停止
- [多活两年](多活两年/README.md)
- [读书思考](读书思考/README.md)
- [](酒/README.md)

View File

@@ -1,191 +0,0 @@
# docsify 侧边栏自动生成脚本
# docsify sidebar automatically generates scripts
> 打包成exe文件程序大小约为5M还是比较轻量的主要文件有
> 1. buildSidebar.exe -> 执行程序后在config.ini设置的根目录下文件夹生成READMD.md和_sidebar.md名称可自定义
> 2. config.ini -> 配置生成文件的一些输出文件\忽略情况等选项,具体可以看config.ini文件中注释
docsify好像没法自动读取文件夹目录结构并且展示在页面上,需要对每个文件夹配置_sidebar.md文件
所以我尝试用python做了一个脚本,基本就用到了os库中的一些函数,所以打包成exe文件大小在可以接受的范围里面,只有5M左右
该程序运行的配置参数依赖于config.ini,所以使用前请将config.ini和builSidebar.exe放在同一个目录下
在生成md文件结构时,有时想要**忽略一些文件**或者**"_"开头的文件夹**,可以通过config.ini配置
```ini
[config]
# docsify根目录
base_dir=D:\MyData\Data\Docsify\docs
# 忽略以“_”,"."开头的文件,如果要添加新文件,用“|”分隔
ignore_start_with=_|.
# 只读取".md"格式问价,如果添加新格式,用“|”分隔
show_file=.md
# 要忽略的文件名,要添加新文件,用“|”分隔
ignore_file_name=README
[outFile]
# 想要在几级目录生成文件,默认"-1"表示所有文件夹生成,"0"表示在根目录生成,可以配合侧边栏折叠插件使用
create_depth=0
# 每个文件夹下主页文件名称和侧边栏文件名,默认README.md和_sidebar.md文件想生成其他名称可修改文字或者添加用“|”分隔
eachFile=README.md|_sidebar.md
```
# 举例1
> 在每一个子文件夹下生成文件
原先文件夹的结构是
```
docs
│ .nojekyll
│ ceede.md
│ index.html
│ _coverpage.md
├─PLC
│ │ 电梯群控算法.md
│ │
│ └─最新测试
│ hi回答.md
├─_media
│ Pasted image 20230403194327.png
└─启发式算法
│ 差分进化算法.md
└─测试
测试.md
```
我在config.ini设置忽略:
1. 以"_","."开头的文件
2. 忽略文件名为README的文件
3. 结构中只包括".md"开头的文件
运行程序得到的结构是
```
docs
│ .nojekyll
│ ceede.md
│ index.html
│ README.md
│ _coverpage.md
│ _sidebar.md
├─PLC
│ │ README.md
│ │ _sidebar.md
│ │ 电梯群控算法.md
│ │
│ └─最新测试
│ hi回答.md
│ README.md
│ _sidebar.md
├─_media
│ Pasted image 20230403194327.png
└─启发式算法
│ README.md
│ _sidebar.md
│ 差分进化算法.md
└─测试
README.md
_sidebar.md
测试.md
```
可以看到_media没有被操作,也符合要求
## 图片
在根目录情况:
![img0.png](image/img0.png)
点击PLC之后
![img4.png](image/img4.png)
这种方式生成的结构,点击新文件夹会刷新界面,也可以接受
# 举例2
> 上面的格式中,点击相应文件夹实际上会跳转,如果不想跳转,可以设置config.ini文件的create_depth参数
>
> 当参数为-1时候,则每个文件夹生成文件
>
> 当参数为0时,仅在根目录生成
该功能配合侧边栏折叠效果更好
原先结构
```
docs
│ .nojekyll
│ ceede.md
│ index.html
│ _coverpage.md
├─PLC
│ │ 电梯群控算法.md
│ │
│ └─最新测试
│ hi回答.md
├─_media
│ Pasted image 20230403194327.png
└─启发式算法
│ 差分进化算法.md
└─测试
测试.md
```
config.ini中`create_depth`设为0
生成的新结构
```
docs
│ .nojekyll
│ ceede.md
│ index.html
│ README.md
│ _coverpage.md
│ _sidebar.md
├─PLC
│ │ 电梯群控算法.md
│ │
│ └─最新测试
│ hi回答.md
├─_media
│ Pasted image 20230403194327.png
└─启发式算法
│ 差分进化算法.md
└─测试
测试.md
```
可以看到仅在根目录生成了文件
## 图片
![img.png](image/img.png)
配合侧边栏折叠插件:https://github.com/iPeng6/docsify-sidebar-collapse
![img2.png](image/img2.png)

View File

@@ -1,175 +0,0 @@
from configparser import ConfigParser
from os.path import splitext, basename, join, isdir, relpath, abspath
from os import listdir
import os
# docsify根目录
root_dir='/root/gitee/notes/blog'
# 要处理的文件或文件夹
exclude_start_with=['_','*','.']
exclude_file = ['readme.md']
exclude_dir = ['.vscode','.git']
# 想要在几级目录生成文件,默认"0"表示在根目录生成,可以配合侧边栏折叠插件使用
create_depth=1
def good_file(base_path):
"""
是否需要生成文件
1. 扩展名不是md的不生成
2. 不是README.md _sidebar.md。不生成
3. 在跳过列表里的不生成
:param file_path: 文件路径
:return: 文件名(不包括扩展名)
"""
file_extension = splitext(base_path)[1]
if file_extension != '.md':
return False
base_name = os.path.basename(base_path)
if base_name.lower() in exclude_file:
return False
for item in exclude_start_with:
if base_name.startswith(item):
return False
rel_path = relpath(base_path,root_dir)
for item in exclude_dir:
if rel_path.startswith(item):
return False
return True
def good_dir(base_path):
rel_path = relpath(base_path,root_dir)
for item in exclude_dir:
if rel_path.startswith(item):
return False
for dirpath, dirnames, filenames in os.walk(base_path):
for filename in filenames:
abspath = os.path.join(dirpath,filename)
if good_file(abspath):
return True
return False
def build_next_level(base_path):
'''
创建下一级节点的目录_sidebar.md
todo:排除子目录下没有md文件的子目录
'''
items = sorted(os.listdir(base_path))
result = "\n"
print("build next level:"+base_path + ",items:",items)
for item in items:
abspath = os.path.join(base_path,item)
if isdir(abspath) and good_dir(abspath):
rel_path = relpath(abspath,root_dir)
readme_path = os.path.join(rel_path,"README.md")
result += "- [" + item + "](" + readme_path + ')\n'
basename = os.path.basename(base_path)
# 如果README.md文件不存在则创建
sidebar_path = os.path.join(base_path,"_sidebar.md")
with open(sidebar_path, 'w') as f:
f.write('## '+ basename + '\n')
f.write(result)
def build_full_level(base_path):
'''
创建所有子节点的目录_sidebar.md
'''
print("build full path:"+base_path)
result = deep_traverse(base_path,'')
if '' == result:
return
basename = os.path.basename(base_path)
sidebar_path = os.path.join(base_path,"_sidebar.md")
with open(sidebar_path, 'w') as f:
f.write('## '+ basename + '\n')
f.write(result)
def deep_traverse(base_path,prefix):
'''
深度递归遍历
'''
if os.path.isfile(base_path):
if not good_file(base_path):
return ''
return build_md_item(prefix,base_path)
title = prefix + '- ' + os.path.basename(base_path) + '\n'
result = ''
for item in sorted(os.listdir(base_path)):
abspath = os.path.join(base_path,item)
result += deep_traverse(abspath,prefix+' ')
if '' == result:
return ''
return title + result
def build_readme_now(base_path):
'''
创建当前节点的readme文件指向当前目录下的md文件。
深度小于depth+1 就要生成readme文件
'''
if not good_dir(base_path):
return
print("build readme now:"+base_path)
readme_path = os.path.join(base_path, 'README.md')
basename = os.path.basename(base_path)
# 如果README.md文件不存在则创建
if not os.path.exists(readme_path):
with open(readme_path, 'w') as f:
f.write('## '+ basename + '\n')
f.write(build_md_items('',base_path))
def build_md_items(prefix,base_path):
'''
todo:排除前缀不符合需求的文件
'''
result = "\n"
for item in sorted(os.listdir(base_path)):
abspath = join(base_path, item)
if os.path.isfile(abspath) and good_file(abspath):
result += build_md_item(prefix,abspath)
return result
def build_md_item(prefix,file_path):
base_name = os.path.basename(file_path)
title = os.path.splitext(base_name)[0]
rel_path = relpath(file_path,root_dir)
print(root_dir,file_path,rel_path)
return prefix + "- [" + title + "](" + rel_path + ')\n'
def layer_traverse(base_path,now,depth):
build_readme_now(base_path)
'''
now=depth创建递归目录不再按层遍历
'''
if now >= depth:
build_full_level(base_path)
return
'''
now<depth创建下层目录并继续递归
'''
build_next_level(base_path)
items = listdir(base_path)
for item in items:
node = join(base_path, item)
if isdir(node):
layer_traverse(node,now+1,depth)
if __name__ == "__main__":
'''
如果默认n层目录
第n-1层会生成n层目录的_sidebar
第n层生成之后所有目录的_sidebar
'''
layer_traverse(root_dir,0,create_depth)

View File

@@ -1,62 +0,0 @@
import os
from configparser import ConfigParser
from os.path import splitext, basename, join, isdir, relpath, abspath
from os import listdir
root_dir = '/root/gitee/notes/blog'
def test_walk():
for dirpath, dirnames, filenames in os.walk(root_dir):
print(f"Currently in directory: {dirpath}")
for dirname in dirnames:
print(f"Subdirectory: {dirname}")
for filename in filenames:
print(f"File: {filename}")
def test_list_dir():
dir = os.listdir(root_dir)
print(dir)
def build_next_level(root_path):
'''
创建下一级节点的目录_sidebar.md
'''
print("next_level"+root_path)
def build_full_level(root_path):
'''
创建所有子节点的目录_sidebar.md
'''
print("full_path"+root_path)
def build_readme_now(root_dir):
'''
创建当前节点的readme文件指向当前目录下的md文件。
深度小于depth+1 就要生成readme文件
'''
print("readme:"+root_dir)
def layer_traverse(root,now,depth):
build_readme_now(root)
'''
now=depth创建递归目录不再按层遍历
'''
if now >= depth:
build_full_level(root)
return
'''
now<depth创建下层目录并继续递归
'''
build_next_level(root)
items = listdir(root)
for item in items:
node = join(root, item)
if isdir(node):
layer_traverse(node,now+1,depth)
# test_list_dir()
# test_walk()
layer_traverse(root_dir,0,1)