-
Notifications
You must be signed in to change notification settings - Fork 1
Update readme and docs #26
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
Open
szabo137
wants to merge
12
commits into
main
Choose a base branch
from
uha-update_readme_and_docs
base: main
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 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5bc992d
updated readme, added example
433031d
added available_accessors
62d7f8a
updated docstrings
03b1290
use readme as landing page
8c2cfa6
started updating the docs
6075c02
added tutorial for four vectors + formatting
642be4f
fixed tutorial
83c0020
fixed interface page in docs
b4f42c6
added tutorial for coordinate systems
06261dc
updated example section in readme
be19fe4
applied suggestions
cb746a3
Apply suggestions from code review
szabo137 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 hidden or 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,24 +1,65 @@ | ||
# LorentzVectorBase | ||
|
||
Base interfaces for four-momenta in high-energy physics. | ||
# LorentzVectorBase.jl | ||
|
||
[](https://JuliaHEP.github.io/LorentzVectorBase.jl/stable/) | ||
[](https://JuliaHEP.github.io/LorentzVectorBase.jl/dev/) | ||
[](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Test.yml?query=branch%3Amain) | ||
[](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Docs.yml?query=branch%3Amain) | ||
[](https://codecov.io/gh/JuliaHEP/LorentzVectorBase.jl) | ||
|
||
# Code Formatting | ||
**LorentzVectorBase.jl** provides base interfaces for four-momenta in high-energy physics, facilitating standardized representations and operations on Lorentz vectors. | ||
|
||
## Installation | ||
|
||
Install the package using Julia's package manager: | ||
|
||
```julia | ||
using Pkg | ||
Pkg.add("LorentzVectorBase") | ||
``` | ||
|
||
Alternatively, in the Julia REPL, enter `pkg>` mode by typing `]`, then | ||
|
||
```julia-repl | ||
add LorentzVectorBase | ||
``` | ||
|
||
## Usage | ||
|
||
This package defines abstract interfaces for Lorentz vectors. To utilize concrete implementations, consider packages like [LorentzVectorHEP.jl](https://github.com/JuliaHEP/LorentzVectorHEP.jl) or [FourVectors.jl](https://github.com/mmikhasenko/FourVectors.jl). | ||
|
||
This package follows a standardized formatting configuration to ensure consistency across | ||
the codebase. We enforce these formatting guidelines by running checks on all pull requests | ||
through continuous integration (CI). | ||
## Example | ||
|
||
To format your code locally and ensure it meets the required standards, you can run the | ||
following command in your terminal: | ||
Here is an example of how to define a custom Lorentz vector type and implement the required interface functions: | ||
|
||
```bash | ||
```Julia | ||
struct CustomLVector | ||
x | ||
y | ||
z | ||
t | ||
end | ||
|
||
LorentzVectorBase.coordinate_system(::CustomLVector) = LorentzVectorBase.XYZT() | ||
LorentzVectorBase.x(lv::CustomLVector) = lv.x | ||
LorentzVectorBase.y(lv::CustomLVector) = lv.y | ||
LorentzVectorBase.z(lv::CustomLVector) = lv.z | ||
LorentzVectorBase.t(lv::CustomLVector) = lv.t | ||
|
||
|
||
c = CustomLVector(1,2,3,4) | ||
@assert isapprox(LorentzVectorBase.spatial_magnitude(c), sqrt(1^2 + 2^2 + 3^2)) | ||
``` | ||
|
||
## Code Formatting | ||
|
||
To maintain code consistency, format your code with: | ||
|
||
```julia | ||
julia --project=.formatting -e 'using Pkg; Pkg.instantiate(); include(".formatting/format_all.jl")' | ||
``` | ||
|
||
This will apply the necessary formatting rules to your code before submission. | ||
This ensures adherence to the project's formatting standards. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. |
This file contains hidden or 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,3 +1,4 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" | ||
LorentzVectorBase = "592a752d-6533-4762-a71b-738712ea30ec" |
This file contains hidden or 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 |
---|---|---|
|
@@ -7,28 +7,81 @@ Pkg.develop(; path=project_path) | |
|
||
using LorentzVectorBase | ||
using Documenter | ||
using Literate | ||
|
||
DocMeta.setdocmeta!( | ||
LorentzVectorBase, :DocTestSetup, :(using LorentzVectorBase); recursive=true | ||
) | ||
|
||
# some paths for links | ||
readme_path = joinpath(project_path, "README.md") | ||
index_path = joinpath(project_path, "docs/src/index.md") | ||
license_path = "https://github.com/QEDjl-project/QEDcore.jl/blob/main/LICENSE" | ||
|
||
# Copy README.md from the project base folder and use it as the start page | ||
open(readme_path, "r") do readme_in | ||
readme_string = read(readme_in, String) | ||
|
||
# replace relative links in the README.md | ||
readme_string = replace(readme_string, "[MIT](LICENSE)" => "[MIT]($(license_path))") | ||
|
||
open(index_path, "w") do readme_out | ||
write(readme_out, readme_string) | ||
end | ||
end | ||
|
||
# setup examples using Literate.jl | ||
literate_paths = [ | ||
Base.Filesystem.joinpath(project_path, "docs/src/tutorial/20-new_four_vector.jl"), | ||
Base.Filesystem.joinpath(project_path, "docs/src/tutorial/21-new_coord_system.jl"), | ||
] | ||
|
||
tutorial_output_dir = joinpath(project_path, "docs/src/generated/") | ||
!ispath(tutorial_output_dir) && mkdir(tutorial_output_dir) | ||
@info "Literate: create temp dir at $tutorial_output_dir" | ||
|
||
tutorial_output_dir_name = splitpath(tutorial_output_dir)[end] | ||
|
||
pages = [ | ||
"Home" => "index.md", "Interface" => "10-interface.md", "Reference" => "95-reference.md" | ||
"Home" => "index.md", | ||
"Interface" => "10-interface.md", | ||
"Tutorial" => [ | ||
"New Four-Vector" => joinpath(tutorial_output_dir_name, "20-new_four_vector.md"), | ||
"New Coordinate System" => | ||
joinpath(tutorial_output_dir_name, "21-new_coord_system.md"), | ||
], | ||
"Contributors guide" => "90-contributing.md", | ||
"Developer docs" => "91-dev_docs.md", | ||
"API Reference" => "95-reference.md", | ||
] | ||
|
||
makedocs(; | ||
modules=[LorentzVectorBase], | ||
authors="Uwe Hernandez Acosta <[email protected]>", | ||
repo=Documenter.Remotes.GitHub("JuliaHEP", "LorentzVectorBase.jl"), | ||
sitename="LorentzVectorBase.jl", | ||
format=Documenter.HTML(; | ||
prettyurls=get(ENV, "CI", "false") == "true", | ||
canonical="https://JuliaHEP.github.io/LorentzVectorBase.jl", | ||
# repolink="https://github.com/JuliaHEP/LorentzVectorBase.jl", | ||
# edit_link="main", | ||
assets=String[], | ||
), | ||
pages=pages, | ||
) | ||
try | ||
|
||
# generate markdown files with Literate.jl | ||
for file in literate_paths | ||
Literate.markdown(file, tutorial_output_dir; documenter=true) | ||
end | ||
makedocs(; | ||
modules=[LorentzVectorBase], | ||
authors="Uwe Hernandez Acosta <[email protected]>", | ||
repo=Documenter.Remotes.GitHub("JuliaHEP", "LorentzVectorBase.jl"), | ||
sitename="LorentzVectorBase.jl", | ||
format=Documenter.HTML(; | ||
prettyurls=get(ENV, "CI", "false") == "true", | ||
canonical="https://JuliaHEP.github.io/LorentzVectorBase.jl", | ||
# repolink="https://github.com/JuliaHEP/LorentzVectorBase.jl", | ||
# edit_link="main", | ||
assets=String[], | ||
), | ||
pages=pages, | ||
) | ||
|
||
deploydocs(; repo="github.com/JuliaHEP/LorentzVectorBase.jl", push_preview=true) | ||
finally | ||
# doing some garbage collection | ||
@info "GarbageCollection: remove generated landing page" | ||
rm(index_path) | ||
|
||
deploydocs(; repo="github.com/JuliaHEP/LorentzVectorBase.jl", push_preview=true) | ||
@info "GarbageCollection: remove generated tutorial files" | ||
rm(tutorial_output_dir; recursive=true) | ||
end |
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.
Uh oh!
There was an error while loading. Please reload this page.