Skip to content

Commit

Permalink
0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed May 23, 2021
1 parent 6c71c42 commit 61bceaa
Show file tree
Hide file tree
Showing 24 changed files with 756 additions and 486 deletions.
65 changes: 40 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
[package]
name = "ftd"
version = "0.1.2"
authors = [
"Amit Upadhyay <[email protected]>",
"mxfunc <[email protected]>",
"Abrar Khan <[email protected]>"
]
description = "FifthTry Document Language"
license-file = "LICENSE"
include = ["src/**/*", "Cargo.toml"]
readme = "README.md"
keywords = ["fifthtry"]
version = "0.1.3"
authors = ["Amit Upadhyay <[email protected]>"]
edition = "2018"
description = "ftd: FifthTry Document Format parser"
license = "MIT"
repository = "https://github.com/fifthtry/ftd"
homepage = "https://www.fifthtry.com/fifthtry/ftd/"

[features]
default = []
fifthtry = [
"comrak",
"lazy_static",
"linked-hash-map",
"percent-encoding",
"serde",
"serde_derive",
"syntect",
"css-color-parser",
"slug",
"katex",
"realm-lang",
"observer",
"rst_renderer",
"rst_parser",
]

[dependencies]
Inflector = "0.11.4"
comrak = "0.7.0"
lazy_static = "1"
linked-hash-map = { version = "0.5.4", features = ["serde_impl"]}
percent-encoding = "2.1.0"
serde = "1"
serde_derive = "1"
syntect = "4"
thiserror = "1"
unindent = "0.1.3"
css-color-parser = "0.1.2"
slug = "0.1.4"
katex = "0.3"
realm-lang = "0.1.0"
observer = "0.2.5"

realm-lang = { path = "../realm/realm-lang", optional = true, version = "0.1.0" }
observer = { path = "../observer/observer", optional = true, version = "0.2.4" }

comrak = { version = "0.7.0", optional = true }
lazy_static = { version = "1", optional = true }
linked-hash-map = { version = "0.5.4", features = ["serde_impl"], optional = true}
percent-encoding = { version = "2.1.0", optional = true }
serde = { version = "1", optional = true }
serde_derive = { version = "1", optional = true }
syntect = { version = "4", optional = true }
css-color-parser = { version = "0.1.2", optional = true }
slug = { version = "0.1.4", optional = true }
katex = { version = "0.3", optional = true }
rst_renderer = { version = '0.4', optional = true }
rst_parser = { version = '0.4', optional = true }

[dev-dependencies]
diffy = "0.2.0"
Expand Down
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
FTD stands for Fifthtry Document Format. Documents on FifthTry are stored in this
format.
# FTD Components

FTD is meant to be universal file format for text based data, think of XML done
right.
## ftd/text

FTD also has a low level parser, [`ftd::p1`](https://www.fifthtry.com/fifthtry/ftd/p1/), which can be used
as a JSON/YML replacement.
This component is to be used to create new text. It accepts
the following arguments:

Discord: Join our [`ftd` channel](https://discord.gg/xN3uD8P7WA).

License: BSD.

Checkout the [Roadmap](https://www.fifthtry.com/fifthtry/ftd/roadmap/) and
[Changelog](https://www.fifthtry.com/fifthtry/ftd/changelog/).
text[string]: Text to be displayed.

size[int=12]: Size in pixels.
19 changes: 12 additions & 7 deletions src/api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::document::ParseError;

#[derive(PartialEq, Debug, Clone, Serialize)]
#[derive(PartialEq, Debug, Clone, serde_derive::Serialize)]
pub enum Method {
Get,
Post,
Expand Down Expand Up @@ -93,8 +93,9 @@ code: 404
*/

#[derive(PartialEq, Debug, Clone, Serialize, Default)]
#[derive(PartialEq, Debug, Clone, serde_derive::Serialize, Default)]
pub struct Api {
pub id: Option<String>,
pub title: String,
pub method: Method,
pub url: String,
Expand All @@ -116,7 +117,8 @@ impl Api {
let mut p1 = crate::p1::Section::with_name("api")
.and_caption(self.title.as_str())
.add_header("method", self.method.as_str())
.add_header("url", self.url.as_str());
.add_header("url", self.url.as_str())
.add_optional_header("id", &self.id);

if let Some(c) = self.description.get("") {
p1 = p1.and_body(c.as_str())
Expand Down Expand Up @@ -148,6 +150,7 @@ impl Api {

pub fn from_p1(p1: &crate::p1::Section) -> Result<Self, crate::document::ParseError> {
let mut m = Api::default();
m.id = p1.header.string_optional("id")?;
m.title = match p1.caption {
Some(ref c) => c.clone(),
None => return Err("title is required".into()),
Expand Down Expand Up @@ -189,8 +192,9 @@ impl Api {
// top: after i open vim
// bottom: asd

#[derive(PartialEq, Debug, Clone, Serialize, Default)]
#[derive(PartialEq, Debug, Clone, serde_derive::Serialize, Default)]
pub struct ApiObject {
pub id: Option<String>,
pub title: Option<String>,
pub name: String,
pub description: String,
Expand All @@ -206,6 +210,7 @@ impl ToString for ApiObject {
impl ApiObject {
pub fn from_p1(p1: &crate::p1::Section) -> Result<Self, crate::document::ParseError> {
let mut m = ApiObject {
id: p1.header.string_optional("id")?,
title: p1.caption.clone(),
name: p1.header.string("name")?,
description: p1.body.clone().unwrap_or_else(|| "".to_string()),
Expand All @@ -222,7 +227,7 @@ impl ApiObject {
}
}

#[derive(PartialEq, Debug, Clone, Serialize, Default)]
#[derive(PartialEq, Debug, Clone, serde_derive::Serialize, Default)]
pub struct Parameter {
pub name: String,
#[serde(rename = "type")]
Expand Down Expand Up @@ -253,7 +258,7 @@ impl Parameter {
}
}

#[derive(PartialEq, Debug, Clone, Serialize, Default)]
#[derive(PartialEq, Debug, Clone, serde_derive::Serialize, Default)]
pub struct Example {
pub title: Option<String>,
pub description: Option<String>,
Expand All @@ -278,7 +283,7 @@ impl Example {
}
}

#[derive(PartialEq, Debug, Clone, Serialize, Default)]
#[derive(PartialEq, Debug, Clone, serde_derive::Serialize, Default)]
pub struct Error {
code: String,
message: String,
Expand Down
Loading

0 comments on commit 61bceaa

Please sign in to comment.