Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e6d6f53

Browse files
authoredJan 13, 2019
Merge pull request #22 from jkuczm/paclet
Paclet + sub-package
2 parents 4838aff + 7b9b7d8 commit e6d6f53

File tree

10 files changed

+120
-75
lines changed

10 files changed

+120
-75
lines changed
 

‎.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.directory
22
/build
33
/private
4-
/buildScripts/build.properties
5-
/SyntaxAnnotations.zip
4+
/SyntaxAnnotations-*.*.*.paclet

‎BootstrapInstall.m

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2015 - 2016 Jakub Kuczmarski <Jakub.Kuczmarski@gmail.com>
3+
Copyright (c) 2015 - 2019 Jakub Kuczmarski <Jakub.Kuczmarski@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎NoInstall.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(* ::Package:: *)
2+
3+
4+
Internal`InheritedBlock[{BeginPackage},
5+
Unprotect@BeginPackage;
6+
(* If package is loaded through NoInstall.m it'll be loaded as package
7+
with ordinary "top-level" context. *)
8+
BeginPackage@"`SyntaxAnnotations`" := BeginPackage@"SyntaxAnnotations`";
9+
Protect@BeginPackage;
10+
Import@"https://raw.githubusercontent.com/jkuczm/MathematicaSyntaxAnnotations/master/SyntaxAnnotations/SyntaxAnnotations.m"
11+
]

‎PacletInfo.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
(* Paclet Info File *)
22

3-
(* created 2016/10/21*)
3+
(* created 2019/01/11*)
44

55
Paclet[
66
Name -> "SyntaxAnnotations",
7-
Version -> "0.2.1",
7+
Version -> "0.2.2",
88
MathematicaVersion -> "6+",
99
Description -> "Annotate syntax elements at box level",
1010
Creator -> "Jakub Kuczmarski",
1111
Extensions ->
1212
{
13+
{"Kernel", "Context" ->
14+
{"SyntaxAnnotations`"}
15+
},
1316
{"Documentation", Language -> "English"}
1417
}
1518
]

‎README.md

Lines changed: 82 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Syntax Annotations
22

3-
[![releases](http://img.shields.io/github/release/jkuczm/MathematicaSyntaxAnnotations.svg)](https://github.com/jkuczm/MathematicaSyntaxAnnotations/releases)
4-
[![SemVer 2.0.0](http://img.shields.io/badge/SemVer-2.0.0-brightgreen.svg)](http://semver.org/spec/v2.0.0.html)
5-
[![license MIT](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jkuczm/MathematicaSyntaxAnnotations/blob/master/LICENSE)
6-
[![Mathematica 8.0 - 11.0](http://img.shields.io/badge/Mathematica-8.0 -- 11.0-brightgreen.svg)](#compatibility)
3+
[![releases](https://img.shields.io/github/release/jkuczm/MathematicaSyntaxAnnotations.svg)](https://github.com/jkuczm/MathematicaSyntaxAnnotations/releases)
4+
[![Mathematica 8.0 - 11.0](https://img.shields.io/badge/Mathematica-8.0_--_11.0-brightgreen.svg)](#compatibility)
5+
[![license MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jkuczm/MathematicaSyntaxAnnotations/blob/master/LICENSE)
6+
[![SemVer 2.0.0](https://img.shields.io/badge/SemVer-2.0.0-brightgreen.svg)](http://semver.org/spec/v2.0.0.html)
77

88

99
Annotate syntax elements at box level.
@@ -17,6 +17,7 @@ Annotate syntax elements at box level.
1717
* [Compatibility](#compatibility)
1818
* [Bugs and requests](#bugs-and-requests)
1919
* [Contributing](#contributing)
20+
* [Usage in other packages](#usage-in-other-packages)
2021
* [License](#license)
2122
* [Versioning](#versioning)
2223

@@ -35,36 +36,51 @@ on Mathematica Stack Exchange.
3536

3637
### Automatic installation
3738

38-
To install SyntaxAnnotations package evaluate:
39+
To install newest version of SyntaxAnnotations package,
40+
in *Mathematica* version 10 or newer, evaluate following code:
3941
```Mathematica
40-
Import["https://raw.githubusercontent.com/jkuczm/MathematicaSyntaxAnnotations/master/BootstrapInstall.m"]
42+
PacletInstall@"http://github.com/jkuczm/MathematicaSyntaxAnnotations/releases/download/v0.2.2/SyntaxAnnotations-0.2.2.paclet"
4143
```
4244

43-
Note that this will also install
44-
[ProjectInstaller](https://github.com/lshifr/ProjectInstaller)
45-
package, if you don't have it already installed.
45+
Note that above requires allowing *Mathematica* to use the Internet.
4646

47-
To load SyntaxAnnotations package evaluate: ``Needs["SyntaxAnnotations`"]``.
47+
To load SyntaxAnnotations package evaluate:
48+
```Mathematica
49+
Needs@"SyntaxAnnotations`"
50+
```
51+
52+
To uninstall SyntaxAnnotations package evaluate:
53+
```Mathematica
54+
PacletUninstall@"SyntaxAnnotations"
55+
```
4856

4957

5058
### Manual installation
5159

52-
1. Download latest released
53-
[SyntaxAnnotations.zip](https://github.com/jkuczm/MathematicaSyntaxAnnotations/releases/download/v0.2.1/SyntaxAnnotations.zip)
54-
file.
60+
If in your setup *Mathematica* doesn't have Internet access,
61+
or you're using version older than 10, download
62+
[SyntaxAnnotations.0.2.2.paclet](https://github.com/jkuczm/MathematicaSyntaxAnnotations/releases/download/v0.2.2/SyntaxAnnotations-0.2.2.paclet)
63+
file and evaluate `PacletInstall` with path to downloaded file:
64+
```Mathematica
65+
PacletInstall@"path/to/downloaded/SyntaxAnnotations.0.2.2.paclet"
66+
```
5567

56-
2. Extract downloaded `SyntaxAnnotations.zip` to any directory which is on
57-
*Mathematica* `$Path`, e.g. to one obtained by evaluating
58-
`FileNameJoin[{$UserBaseDirectory,"Applications"}]`.
68+
To load SyntaxAnnotations package evaluate:
69+
```Mathematica
70+
Needs@"SyntaxAnnotations`"
71+
```
5972

60-
3. To load the package evaluate: ``Needs["SyntaxAnnotations`"]``
73+
To uninstall SyntaxAnnotations package evaluate:
74+
```Mathematica
75+
PacletUninstall@"SyntaxAnnotations"
76+
```
6177

6278

6379
### No installation
6480

6581
To use package directly from the Web, without installation, evaluate:
6682
```Mathematica
67-
Import["https://raw.githubusercontent.com/jkuczm/MathematicaSyntaxAnnotations/master/SyntaxAnnotations/SyntaxAnnotations.m"]
83+
Import@"https://raw.githubusercontent.com/jkuczm/MathematicaSyntaxAnnotations/master/NoInstall.m"
6884
```
6985

7086

@@ -77,8 +93,9 @@ Package is tested with all *Mathematica* major and minor versions from 8.0 to
7793
11.0 on Linux. Since it doesn't contain any OS specific code it should work
7894
with above versions on all operating systems.
7995

80-
There's also no obvious reason for package not to work on earlier (6.0+)
81-
versions of *Mathematica*.
96+
There's also no obvious reason for package not to work on older (6.0+)
97+
and newer (11.1+) versions of *Mathematica*,
98+
but it was not tested with these versions.
8299

83100

84101

@@ -93,13 +110,55 @@ If you find any bugs or have feature request please create an
93110

94111
Feel free to fork and send pull requests.
95112

96-
If you want to use Ant scripts from this repository you will also need to
97-
install [WWBCommon](https://github.com/jkuczm/WWBCommon) project.
98-
99113
All contributions are welcome!
100114

101115

102116

117+
## Usage in other packages
118+
119+
There are two ways to use SyntaxAnnotations with your own package.
120+
121+
First is to require users, of your package, to install SyntaxAnnotations
122+
separately. Your package can then load it, as any other external package, using
123+
``Get@"SyntaxAnnotations`"``. Be aware that if your package requires specific
124+
version of SyntaxAnnotations and user wants to use other package requiring
125+
different version of SyntaxAnnotations it may lead to a version conflict.
126+
127+
Second way is to include specific version of SyntaxAnnotations as sub-package
128+
of your package. To do it, simply put `SyntaxAnnotations.m` file inside main
129+
directory of your package. And load it using ``Get@"`SyntaxAnnotations`"``
130+
(note the grave accent character at the beginning of string) somewhere inside
131+
main context of your package.
132+
133+
Directory structure of ``YourPackage` `` can, for example, look like this:
134+
135+
```
136+
YourPackage
137+
├── Kernel
138+
│   └── init.m
139+
├── SyntaxAnnotations.m
140+
└── YourPackage.m
141+
```
142+
143+
and `YourPackage.m` file:
144+
145+
```Mathematica
146+
BeginPackage@"YourPackage`"
147+
(* Public symbols usage *)
148+
Get@"`SyntaxAnnotations`"
149+
Begin@"`Private`"
150+
(* Implementation *)
151+
End[]
152+
EndPackage[]
153+
```
154+
155+
This way specific version of SyntaxAnnotations package, distributed with your
156+
package, will be loaded as ``YourPackage`SyntaxAnnotations` ``, and will be
157+
completely independent of other versions of SyntaxAnnotations possibly used by
158+
user of your package.
159+
160+
161+
103162
## License
104163

105164
This package is released under

‎SyntaxAnnotations/Kernel/init.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
(* Mathematica Init File *)
22

3-
Get[ "SyntaxAnnotations`SyntaxAnnotations`"]
3+
Internal`InheritedBlock[{BeginPackage},
4+
Unprotect@BeginPackage;
5+
(* If package is loaded through init.m it'll be loaded as package with
6+
ordinary "top-level" context. *)
7+
BeginPackage@"`SyntaxAnnotations`" := BeginPackage@"SyntaxAnnotations`";
8+
Protect@BeginPackage;
9+
Get@"SyntaxAnnotations`SyntaxAnnotations`"
10+
]

‎SyntaxAnnotations/SyntaxAnnotations.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
(* ::Package:: *)
22

3-
BeginPackage["SyntaxAnnotations`"]
3+
(* SyntaxAnnotations package
4+
5+
Copyright (c) 2015 - 2019 Jakub Kuczmarski <Jakub.Kuczmarski@gmail.com>
6+
Released under The MIT License
7+
https://github.com/jkuczm/MathematicaSyntaxAnnotations/blob/master/LICENSE *)
8+
9+
10+
(* Begining of package context with ` is intentionall it allows loading
11+
SyntaxAnnotations as a sub-package. Apropriate steps to load package with
12+
SyntaxAnnotations` as "top level" context are taken in Kernel/init.m.
13+
This is inspired by system used in https://github.com/szhorvat/LTemplate *)
14+
BeginPackage["`SyntaxAnnotations`"]
415

516

617
Unprotect["`*"]

‎buildScripts/deploy.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎buildScripts/project.properties

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.