pubdocrules 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. pubdoc/__init__.py +1 -0
  2. pubdoc/__main__.py +5 -0
  3. pubdoc/cli.py +800 -0
  4. pubdoc/compare.py +121 -0
  5. pubdoc/corpus.py +245 -0
  6. pubdoc/fonts/DejaVuSans-Bold.ttf +0 -0
  7. pubdoc/fonts/DejaVuSans.ttf +0 -0
  8. pubdoc/fonts/LICENCE-Ubuntu.txt +96 -0
  9. pubdoc/fonts/LICENSE-DejaVu.txt +78 -0
  10. pubdoc/fonts/LICENSE-Liberation.txt +130 -0
  11. pubdoc/fonts/LiberationSans-Bold.ttf +0 -0
  12. pubdoc/fonts/LiberationSans-BoldItalic.ttf +0 -0
  13. pubdoc/fonts/LiberationSans-Italic.ttf +0 -0
  14. pubdoc/fonts/LiberationSans-Regular.ttf +0 -0
  15. pubdoc/fonts/README.md +21 -0
  16. pubdoc/fonts/Ubuntu-R.ttf +0 -0
  17. pubdoc/projects.py +501 -0
  18. pubdoc/registry.py +54 -0
  19. pubdoc/schema/doc.schema.json +14 -0
  20. pubdoc/schema/project.schema.json +142 -0
  21. pubdoc/schema/pubdoc.schema.json +16 -0
  22. pubdoc/settings.py +66 -0
  23. pubdoc/storage.py +126 -0
  24. pubdoc/templates/annotations.mjs +116 -0
  25. pubdoc/templates/charged-ieee/template.typ +41 -0
  26. pubdoc/templates/charged-ieee/template.yml +28 -0
  27. pubdoc/templates/cv-sidebar/cv-sidebar.typ +113 -0
  28. pubdoc/templates/cv-sidebar/template.typ +11 -0
  29. pubdoc/templates/cv-sidebar/template.yml +23 -0
  30. pubdoc/templates/lapreprint-typst/LICENSE +21 -0
  31. pubdoc/templates/lapreprint-typst/frontmatter.typ +244 -0
  32. pubdoc/templates/lapreprint-typst/lapreprint.typ +314 -0
  33. pubdoc/templates/lapreprint-typst/template.typ +112 -0
  34. pubdoc/templates/lapreprint-typst/template.yml +82 -0
  35. pubdoc/templates/linkedin-text.mjs +127 -0
  36. pubdoc/templates/pub-plugin.mjs +117 -0
  37. pubdoc/versions.py +383 -0
  38. pubdocrules-0.5.0.dist-info/METADATA +355 -0
  39. pubdocrules-0.5.0.dist-info/RECORD +43 -0
  40. pubdocrules-0.5.0.dist-info/WHEEL +5 -0
  41. pubdocrules-0.5.0.dist-info/entry_points.txt +2 -0
  42. pubdocrules-0.5.0.dist-info/licenses/LICENSE +202 -0
  43. pubdocrules-0.5.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,112 @@
1
+ #import "lapreprint.typ": *
2
+ #show: template.with(
3
+ title: "[-doc.title-]",
4
+ [# if parts.abstract or parts.summary #]
5
+ abstract: (
6
+ [# if parts.abstract #]
7
+ (
8
+ title: "Abstract",
9
+ content: [
10
+ [-parts.abstract-]
11
+ ]
12
+ ),
13
+ [# endif #]
14
+ [# if parts.summary #]
15
+ (
16
+ title: "Plain Language Summary",
17
+ content: [
18
+ [-parts.summary-]
19
+ ]
20
+ ),
21
+ [# endif #]
22
+ ),
23
+ [# endif #]
24
+ [# if doc.subtitle #]
25
+ subtitle: "[-doc.subtitle-]",
26
+ [# endif #]
27
+ [# if doc.short_title #]
28
+ short-title: "[-doc.short_title-]",
29
+ [# endif #]
30
+ [# if options.short_citation #]
31
+ short-citation: "[-options.short_citation-]",
32
+ [# endif #]
33
+ [# if options.heading_numbering #]
34
+ heading-numbering: "[-options.heading_numbering-]",
35
+ [# endif #]
36
+ [# if options.theme #]
37
+ theme: [-options.theme-],
38
+ [# endif #]
39
+ [# if doc.open_access !== undefined #]
40
+ open-access: [-doc.open_access-],
41
+ [# endif #]
42
+ [# if doc.doi #]
43
+ doi: "[-doc.doi-]",
44
+ [# endif #]
45
+ [# if doc.date #]
46
+ date: datetime(
47
+ year: [-doc.date.year-],
48
+ month: [-doc.date.month-],
49
+ day: [-doc.date.day-],
50
+ ),
51
+ [# endif #]
52
+ [# if doc.keywords #]
53
+ keywords: (
54
+ [#- for keyword in doc.keywords -#]"[-keyword-]",[#- endfor -#]
55
+ ),
56
+ [# endif #]
57
+ [# if doc.bibtex #]
58
+ bibliography-file: "[-doc.bibtex-]",
59
+ [# endif #]
60
+ authors: (
61
+ [# for author in doc.authors #]
62
+ (
63
+ name: "[-author.name-]",
64
+ [# if author.orcid #]
65
+ orcid: "[-author.orcid-]",
66
+ [# endif #]
67
+ [# if author.affiliations #]
68
+ affiliations: "[#- for aff in author.affiliations -#][-aff.index-][#- if not loop.last -#],[#- endif -#][#- endfor -#]",
69
+ [# endif #]
70
+ ),
71
+ [# endfor #]
72
+ ),
73
+ affiliations: (
74
+ [# for aff in doc.affiliations #]
75
+ (
76
+ id: "[-aff.index-]",
77
+ name: "[-aff.name-]",
78
+ ),
79
+ [# endfor #]
80
+ ),
81
+ [# if doc.venue.title #]
82
+ venue: "[-doc.venue.title-]",
83
+ [# endif #]
84
+ [# if options.logo #]
85
+ logo: "[-options.logo-]",
86
+ [# endif #]
87
+ [# if options.kind #]
88
+ kind: "[-options.kind-]",
89
+ [# endif #]
90
+ margin: (
91
+ [# if parts.acknowledgements #]
92
+ (
93
+ title: "Acknowledgements",
94
+ content: [
95
+ [-parts.acknowledgements-]
96
+ ],
97
+ ),
98
+ [# endif #]
99
+ [# if parts.availability #]
100
+ (
101
+ title: "Data Availability",
102
+ content: [
103
+ [-parts.availability-]
104
+ ],
105
+ ),
106
+ [# endif #]
107
+ ),
108
+ )
109
+
110
+ [-IMPORTS-]
111
+
112
+ [-CONTENT-]
@@ -0,0 +1,82 @@
1
+ jtex: v1
2
+ kind: typst
3
+ title: LaPreprint Typst Template
4
+ description: Easily create beautiful preprints in Typst
5
+ template: template.typ
6
+ files:
7
+ - lapreprint.typ
8
+ - frontmatter.typ
9
+ - template.typ
10
+ - LICENSE
11
+ authors:
12
+ - name: Rowan Cockett
13
+ github: rowanc1
14
+ affiliations:
15
+ - Curvenote
16
+ - name: Franklin Koch
17
+ github: fwkoch
18
+ affiliations:
19
+ - Curvenote
20
+ version: 0.0.1
21
+ license: MIT
22
+ tags:
23
+ - preprint
24
+ - article
25
+ - paper
26
+ thumbnail: ./examples/pixels/files/screenshot.png
27
+ github: https://github.com/myst-templates/lapreprint-typst
28
+ doc:
29
+ - id: title
30
+ required: true
31
+ - id: authors
32
+ required: true
33
+ - id: subtitle
34
+ - id: short_title
35
+ - id: open_access
36
+ - id: keywords
37
+ - id: doi
38
+ - id: venue
39
+ options:
40
+ - id: logo
41
+ type: file
42
+ description: An image path that is shown in the top right of the page
43
+ - id: kind
44
+ type: string
45
+ description: The "kind" of the content, e.g. "Original Research" - shown as the title of the margin content on the first page
46
+ - id: short_citation
47
+ type: string
48
+ description: |
49
+ The short citation used in the document header. By default, it
50
+ is automatically determined from the author names.
51
+ - id: heading_numbering
52
+ type: string
53
+ description: |
54
+ Heading numbering style.
55
+ See also https://typst.app/docs/reference/model/numbering/.
56
+ - id: theme
57
+ type: string
58
+ description: |
59
+ Allows to set the colortheme, e.g. red.darken(30%).
60
+ Default set to blue.darken(30%)
61
+
62
+
63
+ parts:
64
+ - id: abstract
65
+ description: >
66
+ An abstract is a short summary of your research paper or report. A good
67
+ abstract will prepare readers for the detailed information to follow,
68
+ communicate the essence of the article and help readers take away and remember key points.
69
+ max_words: 500
70
+ required: true
71
+ - id: summary
72
+ description: Plain language summary
73
+ max_words: 500
74
+ required: false
75
+ - id: acknowledgements
76
+ description: >
77
+ Acknowledgements printed in the margin
78
+ max_words: 500
79
+ - id: availability
80
+ description: >
81
+ Data availability statement printed in the margin
82
+ max_words: 500
@@ -0,0 +1,127 @@
1
+ // Plain-text export of a CV for pasting into LinkedIn, which renders no
2
+ // Markdown and no links in most fields. Usage:
3
+ //
4
+ // ./pubdoc linkedin cv/index.md > linkedin.txt
5
+ //
6
+ // which runs this file from the repo's .pubdoc/templates/, in the repo's
7
+ // root, so pub-plugin.mjs finds that repo's publets-local.json.
8
+ //
9
+ // Reads the same index.md the PDF is built from, resolves {pub} tags via
10
+ // the shared publet registry, and prints (1) a deduplicated skills list
11
+ // and (2) one block per Employment entry: company, title, dates,
12
+ // per-role skills (its "Key technologies" line), and the bullets as the
13
+ // description, with a character count against LinkedIn's 2000 limit.
14
+ // Only `# Employment` sections are read - not Vendor Management,
15
+ // Education, or Summary.
16
+ import fs from 'node:fs';
17
+ import { resolvePub } from './pub-plugin.mjs';
18
+
19
+ const DESCRIPTION_LIMIT = 2000;
20
+ const SKILLS_LIMIT = 50;
21
+
22
+ const file = process.argv[2];
23
+ if (!file) {
24
+ console.error('usage: node linkedin-text.mjs <path/to/index.md>');
25
+ process.exit(1);
26
+ }
27
+
28
+ const PUB = /\{pub\}`([^`]+)`/g;
29
+
30
+ // Skill names are always the singular form, even where the CV says "LLMs".
31
+ function pubTexts(line) {
32
+ return [...line.matchAll(PUB)].map((m) => {
33
+ const { publet, text, localName } = resolvePub(m[1].replace(/\+$/, ''));
34
+ if (!publet) throw new Error(`unknown {pub} name "${localName}"`);
35
+ return text;
36
+ });
37
+ }
38
+
39
+ function plain(line) {
40
+ return line
41
+ .replace(PUB, (_, body) => {
42
+ const { publet, text, localName } = resolvePub(body);
43
+ if (!publet) throw new Error(`unknown {pub} name "${localName}"`);
44
+ return text;
45
+ })
46
+ .replace(/\*+/g, '')
47
+ .replace(/\\\$/g, '$')
48
+ .trim();
49
+ }
50
+
51
+ const lines = fs.readFileSync(file, 'utf8').split('\n');
52
+ const entries = [];
53
+ const skillCounts = new Map(); // lowercase text -> { text, count, first }
54
+ let order = 0;
55
+ function noteSkill(text) {
56
+ const k = text.toLowerCase();
57
+ const cur = skillCounts.get(k) ?? { text, count: 0, first: order++ };
58
+ cur.count += 1;
59
+ skillCounts.set(k, cur);
60
+ }
61
+
62
+ let section = null;
63
+ let current = null;
64
+ let bullet = null;
65
+ for (const raw of lines) {
66
+ const h = raw.match(/^# (.+)$/);
67
+ if (h) {
68
+ section = h[1].trim();
69
+ current = bullet = null;
70
+ continue;
71
+ }
72
+ if (section === 'Technical Skills') {
73
+ for (const t of pubTexts(raw)) noteSkill(t);
74
+ continue;
75
+ }
76
+ if (section !== 'Employment') continue;
77
+
78
+ const head = raw.match(/^\*\*(.+?)\*\*\s*(.*)$/);
79
+ if (head && !head[1].startsWith('Key technologies')) {
80
+ const full = head[1];
81
+ const cut = full.lastIndexOf(',');
82
+ current = {
83
+ company: cut === -1 ? full : full.slice(0, cut).trim(),
84
+ title: cut === -1 ? '' : full.slice(cut + 1).trim(),
85
+ dates: head[2].trim().replace(/\.$/, ''),
86
+ skills: [],
87
+ bullets: [],
88
+ };
89
+ entries.push(current);
90
+ bullet = null;
91
+ continue;
92
+ }
93
+ if (!current) continue;
94
+ if (raw.startsWith('**Key technologies:**')) {
95
+ current.skills = pubTexts(raw);
96
+ current.skills.forEach((t) => noteSkill(t));
97
+ bullet = null;
98
+ continue;
99
+ }
100
+ if (raw.startsWith('- ')) {
101
+ bullet = plain(raw.slice(2));
102
+ current.bullets.push(bullet);
103
+ } else if (/^\s+\S/.test(raw) && bullet !== null) {
104
+ current.bullets[current.bullets.length - 1] += ' ' + plain(raw);
105
+ } else {
106
+ bullet = null;
107
+ }
108
+ }
109
+
110
+ const skills = [...skillCounts.values()].sort((a, b) => b.count - a.count || a.first - b.first);
111
+ const out = [];
112
+ out.push(`SKILLS (${skills.length} of LinkedIn's ${SKILLS_LIMIT} max) - add one at a time, most-used first`);
113
+ out.push('');
114
+ skills.forEach((s) => out.push(s.text));
115
+
116
+ for (const e of entries) {
117
+ const description = e.bullets.map((b) => `• ${b}`).join('\n');
118
+ const n = description.length;
119
+ out.push('', '='.repeat(60));
120
+ out.push(`Company: ${e.company}`);
121
+ out.push(`Title: ${e.title}`);
122
+ out.push(`Dates: ${e.dates}`);
123
+ if (e.skills.length) out.push(`Skills: ${e.skills.join(', ')}`);
124
+ out.push('', `Description (${n}/${DESCRIPTION_LIMIT} chars${n > DESCRIPTION_LIMIT ? ' - TOO LONG' : ''}):`);
125
+ out.push(description);
126
+ }
127
+ console.log(out.join('\n'));
@@ -0,0 +1,117 @@
1
+ // Shared MyST plugin: a central publet registry, usable by any document.
2
+ //
3
+ // A "publet" is a short, standalone reference to one concept (a
4
+ // technology, standard, or company) - its own small Markdown file under
5
+ // publets/, with frontmatter (id, url, text, optional plural) plus a
6
+ // one-paragraph synopsis as the body. Two-level indirection, on purpose:
7
+ //
8
+ // {pub}`key` in index.md
9
+ // -> publets-local.json maps "key" to a global id (stable even if
10
+ // the key, the file it lives in, or its display text changes)
11
+ // -> publets/<some-file>.md with that id is the actual publet
12
+ //
13
+ // Why two levels instead of one flat registry (the old links.json): a
14
+ // publet's *id* is what makes it "the same Python reference" everywhere
15
+ // it's used, independent of what any one document calls it.
16
+ // publets-local.json is the consuming repo's own shared namespace of
17
+ // short names for the publets actually used across every doc there -
18
+ // one file, not one per document - so cv/ and cover-letter/ both
19
+ // resolve `python` through the same local name.
20
+ //
21
+ // publets/ and publets-local.json are content, so they live in the
22
+ // consuming repo, not in pubdoc: the plugin walks up from the current
23
+ // directory (the doc directory, where `pubdoc build` runs curvenote) to
24
+ // the first directory holding a publets-local.json, and reads
25
+ // publets/ next to it.
26
+ //
27
+ // Local names are lowercase; the lookup lowercases the call's name so
28
+ // {pub}`TiDB` and {pub}`tidb` are the same thing.
29
+ //
30
+ // A trailing `+` on the role body requests the plural form, computed as
31
+ // `entry.plural ?? (entry.text + "s")` - no second registry entry, no
32
+ // duplicated url/id: {pub}`llm+` renders "LLMs".
33
+ //
34
+ // The publet's synopsis becomes the link's `title` - the same mdast
35
+ // field a literal `[text](url "title")` sets - so it needs no
36
+ // Typst/HTML-specific handling: HTML renders it as a hover tooltip,
37
+ // Typst's exporter just ignores an mdast field it doesn't use (no
38
+ // visible change in the PDF).
39
+ import fs from 'node:fs';
40
+ import path from 'node:path';
41
+
42
+ function findRegistryRoot(start) {
43
+ for (let dir = path.resolve(start); ; dir = path.dirname(dir)) {
44
+ if (fs.existsSync(path.join(dir, 'publets-local.json'))) return dir;
45
+ if (path.dirname(dir) === dir) {
46
+ throw new Error(`pub-plugin: no publets-local.json in ${start} or any parent directory`);
47
+ }
48
+ }
49
+ }
50
+
51
+ const registryRoot = findRegistryRoot(process.cwd());
52
+
53
+ function parsePubletFile(filePath) {
54
+ const lines = fs.readFileSync(filePath, 'utf8').split('\n');
55
+ if (lines[0].trim() !== '---') {
56
+ throw new Error(`${filePath}: expected frontmatter delimited by "---"`);
57
+ }
58
+ const frontmatter = {};
59
+ let i = 1;
60
+ for (; i < lines.length && lines[i].trim() !== '---'; i++) {
61
+ const line = lines[i];
62
+ const sep = line.indexOf(': ');
63
+ if (sep === -1) continue;
64
+ frontmatter[line.slice(0, sep).trim()] = line.slice(sep + 2).trim();
65
+ }
66
+ const synopsis = lines.slice(i + 1).join('\n').trim();
67
+ return { ...frontmatter, id: Number(frontmatter.id), synopsis };
68
+ }
69
+
70
+ const publetsDir = path.join(registryRoot, 'publets');
71
+ const publetsById = new Map();
72
+ for (const filename of fs.readdirSync(publetsDir)) {
73
+ if (!filename.endsWith('.md')) continue;
74
+ const publet = parsePubletFile(path.join(publetsDir, filename));
75
+ publetsById.set(publet.id, publet);
76
+ }
77
+
78
+ const localRegistry = JSON.parse(
79
+ fs.readFileSync(path.join(registryRoot, 'publets-local.json'), 'utf8'),
80
+ );
81
+
82
+ // Shared lookup, also used by linkedin-text.mjs: resolves a {pub} body
83
+ // ("key" or "key+") to its publet and display text, or null if unknown.
84
+ export function resolvePub(body) {
85
+ const wantsPlural = body.endsWith('+');
86
+ const localName = wantsPlural ? body.slice(0, -1) : body;
87
+ const id = localRegistry[localName.toLowerCase()];
88
+ const publet = id === undefined ? undefined : publetsById.get(id);
89
+ if (!publet) return { localName, publet: null, text: null };
90
+ const text = wantsPlural ? (publet.plural ?? `${publet.text}s`) : publet.text;
91
+ return { localName, publet, text };
92
+ }
93
+
94
+ function publetRole() {
95
+ return {
96
+ name: 'pub',
97
+ body: { type: String, required: true },
98
+ run(data) {
99
+ const { localName, publet, text } = resolvePub(data.body);
100
+ if (!publet) {
101
+ // Visibly broken in every export rather than silently vanishing,
102
+ // so a typo'd local name is obvious at a glance.
103
+ return [{ type: 'text', value: `[[pub: unknown local name "${localName}"]]` }];
104
+ }
105
+ const node = { type: 'link', url: publet.url, children: [{ type: 'text', value: text }] };
106
+ if (publet.synopsis) node.title = publet.synopsis;
107
+ return [node];
108
+ },
109
+ };
110
+ }
111
+
112
+ const pubPlugin = {
113
+ name: 'Central publet registry',
114
+ roles: [publetRole()],
115
+ };
116
+
117
+ export default pubPlugin;