-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Searching the documentation with filters #131
Open
polibb
wants to merge
37
commits into
leanprover-community:master
Choose a base branch
from
polibb:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
6dbc6f0
setup branch
polibb 3b931f6
Merge branch 'master' into search-docs
polibb 353ff0d
Merge branch 'master' into search-docs
polibb c6711a7
improve code readability
polibb 80686ab
Merge branch 'master' into search-docs
polibb e23988f
minor fixes
polibb c48b293
python script readability improvements
polibb 6b4bfc3
Merge branch 'master' into search-docs
polibb 7110fa7
extract data structures for readability
polibb ab0e46f
fix build
robertylewis 67b7951
use class instead of dict for structure field names
robertylewis 1228ce8
Merge pull request #1 from leanprover-community/search-docs
polibb 67287f0
Merge pull request #2 from leanprover-community/search-docs-class
polibb d965133
small fixes
polibb ac59932
main py script structure fixes
polibb 7341c7d
Merge branch 'search-docs' of https://github.com/pokixu/doc-gen into …
polibb a932deb
Merge branch 'master' into search-docs
polibb be8c23e
Merge branch 'master' into search-docs
polibb 15eb701
cleanup comments
polibb a37d600
searchable data export structure
polibb ccb7abf
searchable data lists per file name
polibb e7f6812
data structure for searching done
polibb d8212ca
searchable json holds files togethere with declarations
polibb c21ebe6
Merge branch 'master' into search-docs
polibb 8d4da88
building leanpkg increases commit #
polibb 8dddd0a
searching through index; styling; WIP filters
polibb 5432001
add filters to UI
polibb 4c78d9c
show all results implementation
polibb 3d52ff2
clean up and version of mathlib commits up
polibb 0028904
filter searching on top of results
polibb c7a94a3
lean version reference
polibb ada2c1a
no errors on nullable elements; add loading when render all too slow
polibb 8b8b257
Merge remote-tracking branch 'upstream/master'
polibb c01f230
trim query whitespace before searching
polibb 14355ad
remove unnecessary files
polibb d71a7da
Change extension from .json to .bmp
gebner e4765ef
Merge branch 'master' into master
robertylewis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import subprocess | ||
from typing import NamedTuple, List | ||
from pathlib import Path | ||
import json | ||
import toml | ||
|
||
class ImportName(NamedTuple): | ||
project: str | ||
parts: List[str] | ||
raw_path: Path | ||
|
||
@classmethod | ||
def of(cls, fname: str): | ||
fname = Path(fname) | ||
path_info = [(p.resolve(), get_name_from_leanpkg_path(p)) for p in lean_paths] | ||
path_details = "".join(f" - {p}\n" for p, _ in path_info) | ||
|
||
for p, name in path_info: | ||
try: | ||
rel_path = fname.relative_to(p) | ||
except ValueError: | ||
pass | ||
else: | ||
return cls(name, rel_path.with_suffix('').parts, fname) | ||
|
||
raise RuntimeError( | ||
f"Cannot determine import name for {fname}; it is not within any of the directories returned by `lean --path`:\n" | ||
f"{path_details}" | ||
f"Did you generate `export.json` using a different Lean installation to the one this script is running with?") | ||
|
||
@property | ||
def name(self): | ||
return '.'.join(self.parts) | ||
|
||
@property | ||
def url(self): | ||
return '/'.join(self.parts) + '.html' | ||
|
||
def get_name_from_leanpkg_path(p: Path) -> str: | ||
""" get the package name corresponding to a source path """ | ||
if p.parts[-5:] == Path('bin/../lib/lean/library').parts or p.parts[-3:] == Path('bin/../library').parts: | ||
return "core" | ||
|
||
# try the toml | ||
p_leanpkg = p / '..' / 'leanpkg.toml' | ||
try: | ||
f = p_leanpkg.open() | ||
except FileNotFoundError: | ||
pass | ||
else: | ||
with f: | ||
parsed_toml = toml.loads(f.read()) | ||
return parsed_toml['package']['name'] | ||
|
||
return '<unknown>' | ||
|
||
lean_paths = [ | ||
Path(p) | ||
for p in json.loads(subprocess.check_output(['lean', '--path']).decode())['path'] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
[package] | ||
name = "." | ||
version = "0.1" | ||
lean_version = "leanprover-community/lean:3.27.0" | ||
lean_version = "leanprover-community/lean:3.30.0" | ||
path = "src" | ||
|
||
[dependencies] | ||
mathlib = {git = "https://github.com/leanprover-community/mathlib", rev = "97d13d7561ef9c9a21587cf62324f8b2d215a7f8"} | ||
mathlib = {git = "https://github.com/leanprover-community/mathlib", rev = "87adde497c62a4e4e8fdd0fd5cfc46a2d1bd5371"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
class mathlibStructures: | ||
DECLARATIONS = 'decls' | ||
TACTICS = 'tactic_docs' | ||
MODULE_DESCRIPTIONS = 'mod_docs' | ||
NOTES = 'notes' | ||
INSTANCES = 'instances' | ||
|
||
class declaration: | ||
NAME = 'name' | ||
IS_META = 'is_meta' | ||
ARGS = 'args' | ||
TYPE = 'type' | ||
DOC_STRING = 'doc_string' | ||
FILENAME = 'filename' | ||
LINE = 'line' | ||
ATTRIBUTES = 'attributes' | ||
EQUATIONS = 'equations' | ||
KIND = 'kind' | ||
STRUCTURE_FIELDS = 'structure_fields' | ||
CONSTRUCTORS = 'constructors' | ||
|
||
class declarationKindsSource: | ||
THEOREM = 'thm' | ||
CONST = 'cnst' | ||
AXIOM = 'ax' | ||
|
||
class declarationKindsDestination: | ||
STRUCTURE = 'structure' | ||
INDUCTIVE = 'inductive' | ||
THEOREM = 'theorem' | ||
CONST = 'const' | ||
AXIOM = 'axiom' | ||
|
||
class tactic: | ||
NAME = 'name' | ||
CATEGORY = 'category' | ||
DECL_NAMES = 'decl_names' | ||
TAGS = 'tags' | ||
DESCRIPTION = 'description' | ||
IMPORT = 'import' | ||
|
||
class tacticCategories: | ||
TACTIC = 'tactic' | ||
COMMAND = 'command' | ||
HOLE_COMMAND = 'hole_command' | ||
ATTRIBUTE = 'attribute' | ||
|
||
class generalPages: | ||
INDEX = 'index' | ||
TACTICS = 'tactics' | ||
COMMANDS = 'commands' | ||
HOLE_COMMANDS = 'hole_commands' | ||
ATTRIBUTES = 'notes' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, that would make sense to make those inherit from
enum.Enum
also?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try using Enum at first, yes, but there was some issue - not sure what it was since I haven't focused on that in a while. Actually none of the classes here are used at the moment, this is going to be included in another PR which focuses on organizational structure of the python script itself, so that it's easier to read and update. I should probably remove this file from this PR and will look into using Enums again for the next one where those will be needed.