Skip to content
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

Rockspec example added #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# package-template.sile
Template repository for creating new classes or packages
Template repository for creating new classes or packages
25 changes: 25 additions & 0 deletions classes/sample.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local plain = require("classes.plain")

local class = pl.class(plain)
class._name = "sample"

-- This class will inherit the plain's default frameset, if you don't want so just overwrite it below
-- class.defaultFrameset = {
-- content = {
-- left = "",
-- right = "",
-- top = "",
-- bottom = ""
-- }
-- }

function class:_init(options)
plain._init(self, options)
self:loadPackage("template")
end

function class:registerCommands()
plain.registerCommands(self)
end

return class
28 changes: 28 additions & 0 deletions package-template.sile-dev-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package = "package-template.sile"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First line should probably be rockspec_format = "3.0"
(for compatibility)

version = "dev-1"

description = {
summary = "A template for SILE packages...",
detailed = [[]],
homepage = "", -- e.g. its GitHub repo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets go ahead and fill in the blanks throughout the rockspec with working values so it can actually be built and tested from this template repo, but document each line with a -- TODO: ... comment noting that it should be changed after initializing the project.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it can actually be built this way, I had no trouble in my attempts to built and run the test functions...

maintainer = "",
license = "MIT"
}

source = {
url = "", -- a clonable repository link
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took me a while to understand why some of my GitHub packages didn't work in some cases, until someone told me I had to change my initial git: prefix to |git+https: -- And it did the trick. So perhaps we could help the users here, with a working example (or a useful comment)

-- tag = ""
}

dependencies = {}
Copy link
Member

@Omikhleia Omikhleia May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would show an example, and the minimal one might be:

dependencies = {
   "lua >= 5.1",
}

(Assuming this repository also eventually provides an adequate .luacheckrc and a GitHub action, this would be neat.)

build = {
type = "builtin",

modules = {
["sile.packages.template"] = "packages/template/init.lua",
["sile.classes.sample"] = "classes/sample.lua",
},

-- for documentation and config files
copy_directories = {}
}
21 changes: 21 additions & 0 deletions packages/template/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local base = require("packages.base")

local package = pl.class(base)
package._name = "template"

function package:_init()
base._init(self)
end

function package:registerCommands()
self:registerCommand("package-command", function(_, _)
end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could minimally do a SILE.process(content) in these example commands, just processing the content without change.

end

package.documentation = [[
\begin{document}
\autodoc:package{}
Copy link
Member

@Omikhleia Omikhleia May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion (untested): Add some valid example.
E.g.

The \autodoc:package{template} package provides 
a sample \autodoc:command{\package-command{<content>}} command,
which does not do anything useful.

\end{document}
]]

return package