Skip to content

Commit 67b08d0

Browse files
author
Charlie Palm
committed
update readme
1 parent 41419b1 commit 67b08d0

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

MyFirstFormula.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class MyFirstFormula extends NotionFormulaGenerator {
66

77
// fill in your formula function here:
88
formula() {
9-
if (this.myProperty.value) {
9+
if (this.myProperty) {
1010
return 1;
1111
}
1212
return 0;

README.md

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
(updated to support Notion's new formula API!)
77

8-
F.R.A.N.C.I.S. (Formula Readability And Notion Compilation Improvement Stack) is a somewhat complicated but powerful and programmer friendly way of getting around the difficulty of writing large formulas in Notion.
8+
F.R.A.N.C.I.S. (Formula Readability And Notion Compilation Improvement Stack) is a somewhat complicated but powerful and programmer friendly way of getting around the difficulty of writing large formulas in Notion.
99

1010
With this tool you can simply write thoroughly compile/type checked typescript logic (with all of Notion's builtin functions) and have it translated to a formula quick and easy!
1111

@@ -23,8 +23,9 @@ It does so through these steps:
2323
8. Return the completed formula
2424

2525
## Usage
26-
### NPM
26+
This guide assumes basic programming proficiency. You don't really need to be a typescript expert but you should be familiar with the concepts of basic logic and polymorphism
2727

28+
### With npm
2829
Generate a new typescript project:
2930

3031
cd path/to/project
@@ -40,7 +41,7 @@ Then create a MyFirstFormula.ts file that looks something like this:
4041

4142
// fill in your formula function here:
4243
formula() {
43-
if (this.myProperty.value) {
44+
if (this.myProperty) {
4445
return 1;
4546
}
4647
return 0;
@@ -51,10 +52,7 @@ Then create a MyFirstFormula.ts file that looks something like this:
5152
return 0;
5253
}
5354

54-
/**
55-
* If you want to use helper functions, define them here like this
56-
* @returns
57-
*/
55+
// If you want to use helper functions, define them here like this
5856
public buildFunctionMap(): Map<string, string> {
5957
return new Map([
6058
['nameOfFunction', this.nameOfFunction.toString()],
@@ -65,11 +63,13 @@ Then create a MyFirstFormula.ts file that looks something like this:
6563
const formula = new MyFirstFormula();
6664
console.log('result: ');
6765
console.log(formula.compile());
68-
and add your formula and parameters
66+
Then just add your formula and parameters and you can run
67+
68+
ts-node MyFirstFormula.ts
69+
Easy peasy!
6970

70-
### Cloning the repo (Recommended):
71+
### with the whole repo (Recommended):
7172
Because the process for generating formulas is somewhat confusing, it's helpful to have the whole repo at your disposale to view the examples.
72-
This guide assumes basic programming proficiency. You don't really need to be a typescript expert but you should be familiar with the concepts of basic logic and polymorphism
7373

7474
git clone https://github.com/CharliePalm/Francis
7575
cd Francis
@@ -80,9 +80,10 @@ Open the provided myFirstFormula file, and run
8080
you should see the result:
8181

8282
if(prop("myProperty name"),1,0)
83-
Now that you've confirmed that everything is running smoothly, you can start creating your own formula. You can check out the example file at example.ts for a complicated formula example that uses all the functionality of the compiler, or just fill in the myFirstFormula.ts file with all the functionality you need.
83+
Now that you've confirmed that everything is running smoothly, you can start creating your own formula. You can check out the example file at example.ts for a complicated formula example that uses all the functionality of the compiler, or just fill in the MyFirstFormula.ts file with all the functionality you need.
8484

85-
DB properties should be defined as they are in the example file. It doesn't matter what you name the variable, but the string you pass in to the constructor MUST be the name of the property. That is to say, in the following example code:
85+
### General Guidelines
86+
DB properties should be defined as they are in the example. It doesn't matter what you name the variable, but the string you pass in to the constructor MUST be the name of the property. That is to say, in the following example code:
8687

8788
class Formula extends NotionFormulaGenerator {
8889
public test = new Model.Number('test2')
@@ -102,9 +103,9 @@ Aside from these exceptions, if typescript compiles you should be good to go.
102103

103104
Note that when adding functions you must create a mapping function to communicate to the compiler what functions to replace with what code. The parent class itself cannot effectively bind each method of the child class at compile time so it's necessary to add this yourself. See the examples in myFirstFormula.ts or example.ts.
104105

105-
You are allowed to reference other functions within helper functions, but cannot use recursion or call to the formula() method. This includes multi method recursion; the chain of method calls cannot contain a cycle.
106+
You are allowed to reference other functions within helper functions, but cannot use recursion or call to the formula() method. This includes multi method recursion; the chain of method calls cannot contain a cycle, and the compiler will let you know if it encounters one.
106107

107-
If you want to wrap logic in a function call, just execute the logic in a helper function and call it within the function you want to use as the wrapper.
108+
If you want to wrap logic in a function call (i.e. rounding the result of a calculation), just execute the logic in a helper function and call it within the function you want to use as the wrapper.
108109
For example:
109110

110111
formula() {
@@ -128,18 +129,11 @@ Alternatively, you can use ternary operators to the same effect:
128129
}
129130
Which will lead to the same result, just with ternaries instead of the notion if() function.
130131

131-
132132
Above all, this isn't a full complier and shouldn't be treated as such, as the capabilities of Notion formulas are fairly limited. It would be wonderful if the API allowed loops over rollups or dynamic variable definition, it's just not currently possible, and thus I don't see any use cases for things like loops or non-constant variables.
133133

134-
# New in v2.0
135-
136-
Francis has been updated to support Notion's new formula API. This means that you can now utilize object references, callback functions, and update your formulas to be supported by the newest version. Using object references is simple, though does change some ways that Francis needs to be used.
137-
138-
Because DB properties are now treated as objects, if you wish to do any primitive operations, you need to use the .value field on the object (being either a DB property or the return from a function). Otherwise, you can use the object itself as input for things like functions parameters.
139-
140-
Notion also changed some minor things about its builtins - for example: e and pi are now function calls instead of constants, lists have their own functions, concat takes lists, etc.
134+
# New in v2.0.1
141135

142-
Since they now allow new lines, comments, and other such conveniences, the main purpose of this tool has transitioned into more of a complexity manager. Things like helper function and constant declaration will make writing exceptionally complex formulas much simpler and lead to significant readability improvements. See example.ts for my task scheduler algorithm - it uses two sigmoid functions that are contained in function calls.
136+
Francis is now npm ready! Happy formulating!
143137

144138
## FAQ
145139

@@ -161,11 +155,11 @@ You sure can :)\
161155

162156
## Contributing
163157

164-
Submit a pull request (with unit test coverage please) and I'll happily review it. Otherwise you're free to fork and use as you will for your own PERSONAL purposes. If you use a formula generated by this tool for something that isn't exclusively for yourself please, at the bare minimum give it a shout-out :)
158+
Submit a pull request (with unit test coverage please) and I'll happily review it. Otherwise you're free to fork and use as you will for your own PERSONAL purposes. If you use a formula generated by this tool for something that isn't exclusively for yourself please, at the bare minimum give francis a shout-out :)
165159

166160
## Known Bugs
167161

168-
As of 8/5/2023 there are no known bugs.
162+
As of 9/6/2024 there are no known bugs and 100% unit test coverage.
169163

170164
## Reporting Bugs
171165

@@ -178,4 +172,4 @@ contains a value field that has its primitive type (if applicable) for primitive
178172
This brings into question how type safety will be properly enforced and how primitive operations can be carried out, which I don't have a solution for right now, but would like to work more on.
179173

180174
## License
181-
[MIT License](https://opensource.org/licenses/MIT)
175+
[MIT License](https://opensource.org/licenses/MIT)

0 commit comments

Comments
 (0)