Skip to content

Commit 53513ff

Browse files
committed
Lec2&4 cosmetic changes.
1 parent dfc3b6a commit 53513ff

File tree

2 files changed

+56
-60
lines changed

2 files changed

+56
-60
lines changed

docs/src/lecture_02/lecture.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
```@meta
2-
EditURL = "<unknown>/src/lecture_02/lecture.jl"
3-
```
4-
5-
# Motivation
1+
# [Motivation](@id type_lecture)
62

73
````@example lecture
84
using InteractiveUtils # hide

docs/src/lecture_04/lecture.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Package development
1+
# [Package development](@id pkg_lecture)
22

33
Organization of the code is more important with the increasing size of the project and the number of contributors and users. Moreover, it will become essential when different codebases are expected to be combined and reused.
44
- Julia was designed from the beginning to encourage code reuse across different codebases as possible
@@ -32,7 +32,7 @@ export test1
3232
end
3333
```
3434

35-
Function ```include``` copies content of the file to this location (will be part of the module).
35+
Function `include` copies content of the file to this location (will be part of the module).
3636

3737
Creates functions:
3838
```julia
@@ -42,13 +42,13 @@ MySpace.test2
4242

4343
For easier manipulation, these functions can be "exported" to be exposed to the outer world (another namespace).
4444

45-
Keyword: ```using``` exposes the exported functions and structs:
45+
Keyword: `using` exposes the exported functions and structs:
4646
```julia
4747
using .MySpace
4848
```
4949
The dot means that the module was defined in this scope.
5050

51-
Keyword: ```import``` imports function with availability to redefine it.
51+
Keyword: `import` imports function with availability to redefine it.
5252

5353
Combinations:
5454

@@ -78,8 +78,8 @@ When importing/using functions with name that that is already imported/used from
7878
- both function has to be acessed by their full names.
7979

8080
Resoluton:
81-
- It may be easier to cherry pick only the functions we need (rather than importing all via ```using```)
82-
- remane some function using keyword ```as```
81+
- It may be easier to cherry pick only the functions we need (rather than importing all via `using`)
82+
- remane some function using keyword `as`
8383
```julia
8484
import MySpace2: test1 as t1
8585
```
@@ -100,18 +100,18 @@ end;
100100
```
101101

102102
REPL of Julia is a module called "Main".
103-
- modules are not copied, but referenced, i.e. ```B.b===B.C.c ```
103+
- modules are not copied, but referenced, i.e. `B.b===B.C.c`
104104
- including one module twice (from different packages) is not a problem
105105

106106
### Revise.jl
107107

108-
The fact that julia can redefine a function in a Module by importing it is used by package ```Revise.jl``` to synchronize REPL with a module or file.
108+
The fact that julia can redefine a function in a Module by importing it is used by package `Revise.jl` to synchronize REPL with a module or file.
109109

110110
So far, we have worked in REPL. If you have a file that is loaded and you want to modify it, you would need to either:
111111
1. reload the whole file, or
112112
2. copy the changes to REPL
113113

114-
```Revise.jl``` do the latter automatically.
114+
`Revise.jl` do the latter automatically.
115115

116116
Example demo:
117117
```julia
@@ -120,8 +120,8 @@ includet("example.jl")
120120
```
121121

122122
Works with:
123-
- any package loaded with ```import``` or ```using```,
124-
- script loaded with ```includet```,
123+
- any package loaded with `import` or `using`,
124+
- script loaded with `includet`,
125125
- Base julia itself (with Revise.track(Base))
126126
- standard libraries (with, e.g., using Unicode; Revise.track(Unicode))
127127

@@ -148,39 +148,39 @@ Every module introduces a new global scope.
148148

149149
- No variable or function is expected to exist outside of it
150150
- Every module is equal a global scope (no single "global" exists)
151-
- The REPL is a global module called ```Main```
151+
- The REPL is a global module called `Main`
152152

153153
- Local scope
154154

155-
Variables in Julia do not need to be explcitely declared, they are created by assignments: ```x=1```.
155+
Variables in Julia do not need to be explcitely declared, they are created by assignments: `x=1`.
156156

157-
In local scope, the compiler checks if variable ```x``` does not exists outside. We have seen:
157+
In local scope, the compiler checks if variable `x` does not exists outside. We have seen:
158158

159159
```julia
160160
x=1
161161
f(y)=x+y
162162
```
163163

164-
The rules for local scope determine how to treat assignment of ```x```. If local ```x``` exists, it is used, if it does not:
165-
- in *hard* scope: new local ```x``` is created
166-
- in *soft* scope: checks if ```x``` exists outside (global)
167-
- if not: new local ```x``` is created
164+
The rules for local scope determine how to treat assignment of `x`. If local `x` exists, it is used, if it does not:
165+
- in *hard* scope: new local `x` is created
166+
- in *soft* scope: checks if `x` exists outside (global)
167+
- if not: new local `x` is created
168168
- if yes: the split is REPL/non-interactive:
169-
- REPL: global ```x``` is used (convenience, as of 1.6)
170-
- non-interactive: local ```x``` is created
169+
- REPL: global `x` is used (convenience, as of 1.6)
170+
- non-interactive: local `x` is created
171171

172172

173-
- keyword ```local``` and ```global``` can be used to specify which variable to use
173+
- keyword `local` and `global` can be used to specify which variable to use
174174

175175
From documentation:
176176

177177
| Construct | Scope type | Allowed within |
178178
|:----------|:-----------|:---------------|
179-
| [`module`](@ref), [`baremodule`](@ref) | global | global |
180-
| [`struct`](@ref) | local (soft) | global |
181-
| [`for`](@ref), [`while`](@ref), [`try`](@ref try) | local (soft) | global, local |
182-
| [`macro`](@ref) | local (hard) | global |
183-
| functions, [`do`](@ref) blocks, [`let`](@ref) blocks, comprehensions, generators | local (hard) | global, local |
179+
| `module`, `baremodule` | global | global |
180+
| `struct` | local (soft) | global |
181+
| `for`, `while`, `try` | local (soft) | global, local |
182+
| `macro` | local (hard) | global |
183+
| functions, `do` blocks, `let` blocks, comprehensions, generators | local (hard) | global, local |
184184

185185
Question:
186186
```julia
@@ -198,9 +198,9 @@ end
198198
@show x;
199199
```
200200

201-
## Packages
201+
## Packages
202202

203-
Package is a source tree with a standard layout. Can be loaded with ```include``` or ```using``` and provides a module.
203+
Package is a source tree with a standard layout. Can be loaded with `include` or `using` and provides a module.
204204

205205

206206
Minimimal project:
@@ -213,12 +213,12 @@ PackageName/
213213
```
214214

215215
Contains:
216-
- ```Project.toml``` file describing basic properties:
217-
- ```Name```, does not have to be Unique (federated package sources)
218-
- ```UUID```, has to be uniques (generated automatically)
216+
- `Project.toml` file describing basic properties:
217+
- `Name`, does not have to be Unique (federated package sources)
218+
- `UUID`, has to be uniques (generated automatically)
219219
- optionally [deps], [targets],...
220220

221-
- file ```src/PackageName.jl``` that defines module ```PackageName``` which is executed when loaded.
221+
- file `src/PackageName.jl` that defines module `PackageName` which is executed when loaded.
222222

223223

224224
Many other optional directories:
@@ -231,7 +231,7 @@ The package typically loads other modules that form package dependencies.
231231

232232
## Project environments
233233

234-
Is a package that contains additional file ```Manifest.toml```.
234+
Is a package that contains additional file `Manifest.toml`.
235235
This file tracks full dependency tree of a project including versions of the packages on which it depends.
236236

237237
for example:
@@ -250,52 +250,52 @@ uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
250250
version = "0.3.4"
251251
```
252252

253-
Content of files ```Project.toml``` and ```Manifest.toml``` are maintained by PackageManager.
253+
Content of files `Project.toml` and `Manifest.toml` are maintained by PackageManager.
254254

255255
## Package/Project manager
256256

257257
Handles both packages and projects:
258-
- creating a project ```]generate PkgName```
259-
- adding an existing project ```add PkgName``` or ``` add https://github.com/JuliaLang/Example.jl```
258+
- creating a project `]generate PkgName`
259+
- adding an existing project `add PkgName` or ` add https://github.com/JuliaLang/Example.jl`
260260

261261
Names are resolved by Registrators (public or private).
262262

263-
- removing ```]rm PkgName```
264-
- updating ```]update```
265-
- developing ```]dev http://...```
263+
- removing `]rm PkgName`
264+
- updating `]update`
265+
- developing `]dev http://...`
266266

267-
Always reads the actual content of files. ```Add``` creates a precompiled blob.
267+
Always reads the actual content of files. `Add` creates a precompiled blob.
268268

269-
By default these operations are related to environment ```.julia/environments/v1.6```
269+
By default these operations are related to environment `.julia/environments/v1.6`
270270

271-
E.g. running an updating will update packages in ```Manifest.toml``` in this directory. What if the update breaks functionality of some project package that uses special features?
271+
E.g. running an updating will update packages in `Manifest.toml` in this directory. What if the update breaks functionality of some project package that uses special features?
272272

273273
There can be more than one environment!
274274

275275
Any package can define its own project environment with a list of dependencies.
276276

277-
- switching by ```]activate Path```
277+
- switching by `]activate Path`
278278

279279
- from that moment, all package modifications will be relevant only to this project!
280-
- when switching to a new project ```]instantiate``` will prepare (download and precompile) the environment
281-
- which Packages are visible is determined by ```LOAD_PATH```
280+
- when switching to a new project `]instantiate` will prepare (download and precompile) the environment
281+
- which Packages are visible is determined by `LOAD_PATH`
282282
- typically contaings default libraries and default environment
283283
- it is different for REPL and Pkg.tests ! No default env. in tests.
284284

285285
## Unit testing, /test
286286

287287
Without explicit keywords for checking constructs (think missing functions in interfaces), the good quality of the code is guaranteed by detailed unit testing.
288288

289-
- each package should have directory ```/test```
290-
- file ```/test/runtest.jl``` is run by command ```]test``` of the package manager
289+
- each package should have directory `/test`
290+
- file `/test/runtest.jl` is run by command `]test` of the package manager
291291

292-
this file typically contains ```include``` of other tests
292+
this file typically contains `include` of other tests
293293

294294
- no formal structure of tests is prescribed
295295
- test files are just ordinary julia scripts
296296
- user is free to choose what to test and how (freedom x formal rules)
297297

298-
- testing functionality is supported by macros ```@test``` and ```@teststet```
298+
- testing functionality is supported by macros `@test` and `@teststet`
299299

300300
```
301301
@testset "trigonometric identities" begin
@@ -317,7 +317,7 @@ Testset is a collection of tests that will be run and summarized in a common rep
317317
end
318318
```
319319

320-
- Useful macro `````` checks for equality with given tolerance
320+
- Useful macro `` checks for equality with given tolerance
321321

322322
```julia
323323
a=5+1e-8
@@ -372,8 +372,8 @@ PackageName/
372372
```
373373
374374
Where the line-by-line documentation is in the source files.
375-
- ```/docs/src``` folder can contain more detailed information: introductory pages, howtos, tutorials, examples
376-
- running ```make.jl``` controls which pages are generated in what form (html or latex) documentation in the /build directory
375+
- `/docs/src` folder can contain more detailed information: introductory pages, howtos, tutorials, examples
376+
- running `make.jl` controls which pages are generated in what form (html or latex) documentation in the /build directory
377377
- automated with GitHub actions
378378
379379
Documentation is generated by the julia code.
@@ -397,7 +397,7 @@ Documentation is generated by the julia code.
397397
y = MyType("y")
398398
```
399399

400-
See ```?x``` and ```?y```.
400+
See `?x` and `?y`.
401401

402402
It uses the same very standdr building blocks: multiple dispatch.
403403

@@ -409,7 +409,7 @@ If it defines methods that extend previously defined (e.g. from Base), it may af
409409

410410
Julia has a tracking mechanism that stores information about the whole graph of dependencies.
411411

412-
Faster code can be achieved by the ```precompile``` directive:
412+
Faster code can be achieved by the `precompile` directive:
413413
```julia
414414
module FSum
415415

@@ -420,7 +420,7 @@ precompile(fsum,(Float64,Float64,Float64))
420420
end
421421
```
422422

423-
Can be investigated using ```MethodAnalysis```.
423+
Can be investigated using `MethodAnalysis`.
424424

425425
```julia
426426
using MethodAnalysis

0 commit comments

Comments
 (0)