Compare commits
4 Commits
f6bfa6b8fd
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7460d784b6 | |||
| c9976b9c08 | |||
| 9075342661 | |||
| 904ef85f54 |
@@ -40,7 +40,6 @@ def build_mineral(args):
|
||||
with console.status("Compiling", spinner="bouncingBall", spinner_style="green") as status:
|
||||
c_files = find_c_files(args.folder_path)
|
||||
|
||||
print(len(c_files))
|
||||
if len(c_files) == 0:
|
||||
console.print("[b red]digpkg: failed to build mineral: no .c files found in the specified folder, are you sure you're compiling a mineral?[/]")
|
||||
sys.exit(1)
|
||||
|
||||
57
dig/docs.py
57
dig/docs.py
@@ -3,7 +3,10 @@ import os, sys
|
||||
from rich.console import Console
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import MarkdownViewer, Header, Footer
|
||||
from textual.widgets import MarkdownViewer, Header, Footer, Input, Button
|
||||
from textual.containers import Horizontal
|
||||
from textual_autocomplete import PathAutoComplete
|
||||
from textual import on
|
||||
|
||||
|
||||
console = Console()
|
||||
@@ -13,9 +16,45 @@ class DocsApp(App):
|
||||
TITLE = "Digpkg Docs"
|
||||
SUB_TITLE = "made with ❤️ by SpookyDervish"
|
||||
|
||||
CSS = """
|
||||
#search {
|
||||
margin: 1;
|
||||
width: 1fr;
|
||||
}
|
||||
|
||||
#back {
|
||||
margin-top: 1;
|
||||
margin-left: 1;
|
||||
}
|
||||
|
||||
#bottom {
|
||||
height: 5;
|
||||
}
|
||||
"""
|
||||
|
||||
def __init__(self, inital_markdown_path: str):
|
||||
|
||||
super().__init__()
|
||||
self.inital_markdown_path = inital_markdown_path
|
||||
self.docs_folder = os.path.join(os.path.dirname(self.inital_markdown_path), "docs")
|
||||
|
||||
async def on_input_submitted(self, event: Input.Submitted):
|
||||
if event.input.id == "search":
|
||||
|
||||
if not os.path.isdir(self.docs_folder):
|
||||
return
|
||||
|
||||
file_path = os.path.join(self.docs_folder, event.input.value)
|
||||
if os.path.isfile(file_path):
|
||||
event.input.clear()
|
||||
event.input.focus()
|
||||
await self.query_one(MarkdownViewer).go(file_path)
|
||||
else:
|
||||
self.notify("That file wasn't found.", title="Uh oh", severity="error")
|
||||
|
||||
async def on_button_pressed(self, event: Button.Pressed):
|
||||
if event.button.id == "back":
|
||||
await self.query_one(MarkdownViewer).back()
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with open(self.inital_markdown_path, "r") as f:
|
||||
@@ -23,6 +62,22 @@ class DocsApp(App):
|
||||
|
||||
yield Header()
|
||||
yield MarkdownViewer(markdown)
|
||||
|
||||
with Horizontal(id="bottom"):
|
||||
yield Button(label="Back", id="back", flat=True, variant="error")
|
||||
search_input = Input(id="search", placeholder="Search . . .")
|
||||
yield search_input
|
||||
|
||||
|
||||
if os.path.isdir(self.docs_folder):
|
||||
yield PathAutoComplete(
|
||||
search_input,
|
||||
path=self.docs_folder
|
||||
)
|
||||
else:
|
||||
search_input.disabled = True
|
||||
search_input.tooltip = "This mineral doesn't have a docs folder and can't be searched."
|
||||
|
||||
yield Footer()
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# fileio
|
||||
Perform file system operations.
|
||||
|
||||
## Files
|
||||
- [file_Read](docs/read.md)
|
||||
- [file_Write](docs/write.md)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# file_Read
|
||||
Open a file and return the contents in `r` mode.
|
||||
|
||||
## Arguments
|
||||
- path (string): Path to the file you want to read
|
||||
|
||||
## Returns
|
||||
- content (string): Contents of the file
|
||||
|
||||
## Raises
|
||||
- `FileError`: Raised if the file doesn't exist or there was an error allocating memory for the file
|
||||
|
||||
## Example
|
||||
```python
|
||||
call !file_Read "my_file.txt" &contents
|
||||
println $contents
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
# file_Write
|
||||
Open a file and overwrite its contents with the provided string in `w` mode.
|
||||
|
||||
## Arguments
|
||||
- path (string): Path to the file you want to write to
|
||||
|
||||
## Returns
|
||||
- success (boolean): Whether writing to the file succeeded or not
|
||||
|
||||
## Raises
|
||||
- `FileError`: Raised if the file doesn't exist
|
||||
|
||||
## Example
|
||||
```python
|
||||
call !file_Read "my_file.txt" &contents
|
||||
println $contents
|
||||
```
|
||||
@@ -1,5 +0,0 @@
|
||||
[package]
|
||||
description=Provides file I/O support for Ground
|
||||
version=1.2.0
|
||||
|
||||
[dependencies]
|
||||
5
setup.py
5
setup.py
@@ -2,11 +2,12 @@ from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="digpkg",
|
||||
version="1.0",
|
||||
version="1.1",
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
"textual>=7.3.0",
|
||||
"requests>=2.32.5"
|
||||
"requests>=2.32.5",
|
||||
"textual-autocomplete>=4.0.6"
|
||||
],
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# stdlib
|
||||
The standard library for Ground.
|
||||
|
||||
This mineral has no functions because it is intended to just be a collection of minerals needed to do anything useful in Ground.
|
||||
@@ -1,10 +0,0 @@
|
||||
[package]
|
||||
description = Standard library for Ground.
|
||||
version = 1.2.0
|
||||
config_version = 1
|
||||
|
||||
[dependencies]
|
||||
math=1.2.0
|
||||
request=1.2.0
|
||||
fileio=1.2.0
|
||||
|
||||
Reference in New Issue
Block a user