mirror of
https://github.com/mipmip/home-manager-option-search.git
synced 2024-10-26 09:14:19 +03:00
initial import WIP
This commit is contained in:
commit
388d868796
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.nix-gems
|
17
Gemfile.lock
Normal file
17
Gemfile.lock
Normal file
@ -0,0 +1,17 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
mini_portile2 (2.6.1)
|
||||
nokogiri (1.12.5)
|
||||
mini_portile2 (~> 2.6.1)
|
||||
racc (~> 1.4)
|
||||
racc (1.6.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
nokogiri
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# home-manager option search
|
||||
|
||||
## TODO
|
||||
|
||||
- finish nokogiri
|
||||
- write to json
|
||||
- make search front end
|
||||
- github actions
|
42
proto.rb
Normal file
42
proto.rb
Normal file
@ -0,0 +1,42 @@
|
||||
require 'open-uri'
|
||||
require 'nokogiri'
|
||||
require 'json'
|
||||
require 'pp'
|
||||
|
||||
url = 'https://nix-community.github.io/home-manager/options.html'
|
||||
html = open(url)
|
||||
doc = Nokogiri::HTML(html)
|
||||
|
||||
#html body div.appendix div.variablelist
|
||||
|
||||
data = doc.search('dl.variablelist')
|
||||
|
||||
data.search('dt').each do |dt|
|
||||
option_title = dt.text
|
||||
# ct = dt.xpath('count(following-sibling::dt)')
|
||||
# dds = dt.xpath("following-sibling::dd[count(following-sibling::dt)=#{ct}]")
|
||||
dds = dt.xpath("following-sibling::dd[1]")
|
||||
option_desc = dds.children[0].text
|
||||
|
||||
i = 0
|
||||
dds.children.each do | p |
|
||||
i+=1
|
||||
option_example = ""
|
||||
if i == 1
|
||||
option_desc = p.text
|
||||
elsif i == 2
|
||||
option_type = p.text
|
||||
elsif i == 3
|
||||
option_default = p.text
|
||||
elsif i == 4 and p.text.include? "Example"
|
||||
option_example = p.text
|
||||
end
|
||||
|
||||
p "title:" + option_title
|
||||
p "desc:" + option_desc.to_s
|
||||
p "type:" + option_type.to_s
|
||||
p "default:" + option_default.to_s
|
||||
p "example:" + option_example.to_s
|
||||
p ""
|
||||
end
|
||||
end
|
16
shell.nix
Normal file
16
shell.nix
Normal file
@ -0,0 +1,16 @@
|
||||
with (import <nixpkgs> {});
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
ruby_2_7
|
||||
];
|
||||
shellHook = ''
|
||||
mkdir -p .nix-gems
|
||||
export GEM_HOME=$PWD/.nix-gems
|
||||
export GEM_PATH=$GEM_HOME
|
||||
export PATH=$GEM_HOME/bin:$PATH
|
||||
export PATH=$PWD/bin:$PATH
|
||||
|
||||
gem list -i ^bundler$ -v 1.17.3 || gem install bundler --version=1.17.3 --no-document
|
||||
bundle
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user