Reference

by Forum_account
Create custom DM reference pages that appear in Dream Maker's help.
ID:107640
 
Edit: I've packaged this as a somewhat proper library. You can find it at Forum_account.Reference

This is a continuation of my Custom DM Reference Pages blog post from a few months ago.

The DM reference that you see in the Dream Maker program is stored on your computer in the BYOND\help\ref folder as info.html. You can add your own reference entries by adding them to this file. Unfortunately, there are a few problems with this:

1. Dream Maker only reads the file once. If you add something to info.html while Dream Maker is running it won't take effect. You need to restart Dream Maker.

2. It's hard to manage the entries in info.html. You could have your library automatically add entries to the file, but what happens if another library wants to make similar changes? How do you avoid overwriting someone else's changes? How do you avoid writing your same changes multiple times?

3. Documentation is a hassle to maintain.

I haven't thought of a way to address #1. There are some simple (but not ideal) ways to address #2. A proper solution would be more complicated. So, for the time being, I'm working mostly on #3. Here's what I've come up with:

I created a datum called REF, which looks like this:

REF
var
name
title
list/see_also
description
example
library
default_value
format
when
args
returns
default_action


To create a reference page you create a sub-type of this datum. For example:

REF/mob_proc_get_target
name = "/mob/proc/get_target"
title = "get_target proc (mob)"
see_also = list("/mob/proc/set_target","/mob/var/target")
description = "Finds a mob within a certain range of src."
format = "get_target(range)"
args = "range: A number of tiles."
returns = "A mob within r tiles of src."

mob/proc/get_target(range = 3)
for(var/mob/m in oview(3,src))
return m


To generate the content for info.html you generate an instance of each object of the types returned by typesof(/REF). For each instance you generate the HTML and append it to info.html.

This lets you define reference pages in your code. To maintain documentation you don't need to open any additional documents.

Click here to view the complete source code.

Edit: This is now available as a library: Forum_account.Reference

The program also manages info.html by creating a backup of it so an original copy always exists. The new entries are then added to the original. This way you don't have to worry about items being added twice (because multiple copies will show up in the reference).
<-invisible smiley face