Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ A LatticeJSON file for a FODO lattice:
[![CI](https://github.com/andreasfelix/latticejson/workflows/CI/badge.svg)](https://github.com/andreasfelix/latticejson/actions?query=workflow%3ACI)

This repository also contains a Python based command-line tool which is able validate
and convert LatticeJSON files into other common lattice file formats and vice versa.
and convert LatticeJSON files to other common lattice file formats
(e.g. elegant and MAD) and vice versa.

You can install and update it using pip or pipenv:

Expand Down
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.temp
node_modules
36 changes: 36 additions & 0 deletions docs/.vuepress/components/Definition.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div class="definition">
<h3 :id="type.toLowerCase()">
<a :href="'#'+type.toLowerCase()" class="header-anchor">#</a>
{{type}}
</h3>
<p>{{description}}</p>
<table style="width:100%">
<thead>
<tr>
<th>Attribute</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr v-for="attribute, name in attributes">
<td>{{name}}</td>
<td>{{attribute.type}}</td>
<td>{{attribute.description}}</td>
</tr>
</tbody>
</table>
</div>
</template>

<script>
export default {
name: "Definition",
props: {
type: String,
attributes: Object,
description: String
}
};
</script>
57 changes: 57 additions & 0 deletions docs/.vuepress/components/DefinitionList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<div class="definition-list">
<definition
v-for="type in this.elements"
:type="type"
:attributes="elementsAttributes[type]"
:description="elementsDescription[type]"
/>
</div>
</template>

<script>
import Definition from "./Definition.vue";
import SCHEMA from "../../../latticejson/schema.json";
export default {
name: "DefinitionList",
components: Definition,
data() {
return { schema: SCHEMA };
},
created() {
this.schema = SCHEMA;
this.definitions = this.schema.definitions;
this.elements = [];
for (const [type, definition] of Object.entries(this.schema.definitions)) {
if (
!definition.hasOwnProperty("allOf") ||
!definition["allOf"][0].hasOwnProperty("$ref") ||
!definition["allOf"][0]["$ref"] === "#/definitions/Element"
) {
continue;
}

this.elements.push(type);
}

this.elementsAttributes = {};
const attributes_base = this.schema.definitions["Element"].items[1]
.properties;
for (const element of this.elements) {
const attributes_own = this.definitions[element].items[1].properties;
this.elementsAttributes[element] = {};
for (const [key, attribute] of Object.entries(attributes_own)) {
const is_own = Object.entries(attribute).length !== 0;
this.elementsAttributes[element][key] = is_own
? attribute
: attributes_base[key];
}
}

this.elementsDescription = {};
for (const element of this.elements) {
this.elementsDescription[element] = this.definitions[element].description;
}
}
};
</script>
32 changes: 32 additions & 0 deletions docs/.vuepress/components/Schema.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<div class="schema">
<table style="width:100%">
<thead>
<tr>
<th>Property</th>
<th>Required</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr v-for="(value, name) in this.schema.properties">
<td>{{name}}</td>
<td>{{schema.required.includes(name)}}</td>
<td>{{value.type}}</td>
<td>{{value.description}}</td>
</tr>
</tbody>
</table>
</div>
</template>

<script>
import SCHEMA from "../../../latticejson/schema.json";
export default {
name: "Schema",
data() {
return { schema: SCHEMA };
}
};
</script>
20 changes: 20 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
title: 'LatticeJSON',
description: 'A modern lattice file format',
head: [
['link', { rel: "shortcut icon", href: "/favicon.ico" }]
],
temp: ".temp",
ServiceWorker: true,
base: "/latticejson/",
themeConfig: {
logo: '/logo.svg',
nav: [
{ text: 'Reference', link: "/reference" },
{ text: 'GitHub', link: "https://github.com/nobeam/latticejson" },
{ text: 'PyPI', link: "https://pypi.org/project/LatticeJSON/" },
{ text: 'Specification', link: "https://github.com/NoBeam/latticejson/blob/master/latticejson/schema.json" }
],
sidebar: 'auto'
}
};
Binary file added docs/.vuepress/public/favicon.ico
Binary file not shown.
7 changes: 7 additions & 0 deletions docs/.vuepress/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
home: true
heroImage: /logo.svg
heroText: LatticeJSON
tagline: A modern lattice file format
actionText: Reference →
actionLink: /reference/
features:
- title: JSON-Based
details: JSON has become the de-facto standard for data exchange in web applications. It is able to describe complex data structures, has a simple syntax and is available in all common programming language. It is therefore an appropriate choice to characterize the magnetic lattice of a particle accelerator.
- title: CLI tool
details: LatticeJSON comes with an CLI tool, which is able convert lattice files from and to other common formats (like elegant and MAD). It can validate LatticeJSON files upon sytnax as well as logical correctness and can be a real time saver due to its autoformatting capabilites.
- title: Python integration
details: All functionality of the CLI can also be used from Python. Moreover it is possible to load lattices files directly into Python from a given URL.
footer: GPLv3 licensed | Copyright © 2020-present Felix Andreas
---
29 changes: 29 additions & 0 deletions docs/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env sh

# abort on errors
set -e

# change directory to script location
initial_dir="$(pwd)"
cd "$(dirname "$0")"

# build
npm run build

# navigate into the build output directory
cd .vuepress/dist

# if you are deploying to a custom domain
# echo 'www.example.com' > CNAME

git init
git add -A
git commit -m 'deploy'

# if you are deploying to https://<USERNAME>.github.io
# git push -f [email protected]:<USERNAME>/<USERNAME>.github.io.git master

# if you are deploying to https://<USERNAME>.github.io/<REPO>
git push -f [email protected]:nobeam/latticejson.git master:gh-pages

cd initial_dir
Loading