Skip to content

Commit

Permalink
refactor: udpate-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Sep 22, 2023
1 parent dfb7029 commit 002bc37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ You easily add a custom source via the [plugin configuration](#configuration). T
<!-- INFO use `make update_readme` to automatically update this section -->
<!-- auto-generated: start -->
### Rule Lookup
- `selene`
- `pylint`
- `yamllint`
- `stylelint`
- `Lua Diagnostics`
- `eslint`
- `shellcheck`
- `biome`
- `selene`
- `pylint`
- `yamllint`
- `stylelint`

### Add Ignore Comments
- [selene](https://kampfkarren.github.io/selene/usage/filtering.html#allowingdenying-lints-for-an-entire-file)
- [pylint](https://pylint.readthedocs.io/en/latest/user_guide/messages/message_control.html)
- [yamllint](https://yamllint.readthedocs.io/en/stable/disable_with_comments.html)
- [Pyright](https://microsoft.github.io/pyright/#/comments)
- [stylelint](https://stylelint.io/user-guide/ignore-code/)
- [eslint](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1)
- [LTeX](https://valentjn.github.io/ltex/advanced-usage.html)
- [shellcheck](https://www.shellcheck.net/wiki/Ignore)
- [biome](https://biomejs.dev/linter/#ignoring-code)
- [vale](https://vale.sh/docs/topics/config/#markup-based-configuration)
- [typescript](https://www.typescriptlang.org/)
- [selene](https://kampfkarren.github.io/selene/usage/filtering.html#allowingdenying-lints-for-an-entire-file)
- [pylint](https://pylint.readthedocs.io/en/latest/user_guide/messages/message_control.html)
- [yamllint](https://yamllint.readthedocs.io/en/stable/disable_with_comments.html)
- [Pyright](https://microsoft.github.io/pyright/#/comments)
- [stylelint](https://stylelint.io/user-guide/ignore-code/)
<!-- auto-generated: end -->

## Installation
Expand Down
18 changes: 3 additions & 15 deletions lua/rulebook/update-readme.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-- INFO has to be run from lua subdirectory when called via `nvim -l`
-- `cd lua && nvim -l rulebook/update-readme.lua`
-- (it is not indented to be used for other purposes)
--------------------------------------------------------------------------------

-- CONFIG
local readmePath = "../README.md" -- relative to lua directory
Expand All @@ -18,26 +20,12 @@ local function writeToFile(filePath, str)
file:close()
end

---read the full file
---@param filePath string
---@nodiscard
---@return string|nil nil on error
local function readFile(filePath)
local file, _ = io.open(filePath, "r")
if not file then return end
local content = file:read("*a")
file:close()
return content
end

--------------------------------------------------------------------------------

local readmeContent = assert(readFile(readmePath), "README.md not found")

-- remove old lines
local beforePart, afterPart = {}, {}
local removeActive = nil
for line in readmeContent:gmatch("(.-)[\r\n]") do
for line in io.lines(readmePath) do
if removeActive == nil then table.insert(beforePart, line) end
if removeActive == false then table.insert(afterPart, line) end
if line == markerStart then
Expand Down

0 comments on commit 002bc37

Please sign in to comment.