November 24, 2020, 07:10:20 AM

Author Topic: [bmx] Online doc links by markcw [ 1+ years ago ]  (Read 790 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Online doc links by markcw [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Online doc links
Author : markcw
Posted : 1+ years ago

Description : This adds links to the Brl and Pub module docs. It is to make it quicker to look up the BlitzMax online manual.

Obviously doing a Rebuild docs will remove the links again.

Also, it won't add a link if there is one there already and you can run the source file from anywhere under the BlitzMax directory.

It is cross-platform and depending on the way your IDE works, the links will either open in the default browser or directly.

Edit: updated to work as a type.

Code :
Code: BlitzMax
  1. ' Online doc links.bmx
  2. '
  3. ' Adds links to docs/html for all functions in brl and pub modules, links are to online doc
  5. SuperStrict
  7. Local p:AddDocLinks = New AddDocLinks
  9. p.FindFiles(p.FindDocs())
  11. End
  13. Type AddDocLinks
  14.         Field mdir$=FindDocs()
  16.         Method FindDocs$()
  17.                 Local wdir$=CurrentDir()+"/" ' find the docs
  18.                 Local ldir$=wdir.Tolower() ' lowercase
  19.                 Local bms%=ldir.Find("blitzmax",0) ' bmax start
  20.                 If bms=-1 RuntimeError "Failed to find blitzmax directory"
  22.                 Local bme%=ldir.Find("/",bms) ' bmax end
  23.                 Return wdir[..bme]+"/docs/html/Modules" ' modules dir
  24.         End Method
  26.         Method FindFiles(dir$)
  27.                 Local dh%=ReadDir(dir)
  28.                 If Not dh RuntimeError "failed to read current directory"
  30.                 Repeat
  31.                         Local temp$=NextFile(dh)
  32.                         If temp="" Then Exit ' done
  33.                         If temp="." Or temp=".." Continue ' skip
  34.                         Local cfile$=dir+"/"+temp ' current file
  35.                         If FileType(cfile)=2 Then FindFiles2(cfile) ' directory
  36.                 Forever
  38.                 CloseDir dh
  39.         End Method
  41.         Method FindFiles2(dir$)
  42.                 Local dh%=ReadDir(dir)
  43.                 If Not dh RuntimeError "failed to read current directory l2"
  45.                 Repeat
  46.                         Local temp$=NextFile(dh)
  47.                         If temp="" Then Exit ' done
  48.                         If temp="." Or temp=".." Continue ' skip
  49.                         Local cfile$=dir+"/"+temp ' current file
  50.                         If FileType(cfile)=2 Then FindFiles3(cfile) ' directory
  51.                 Forever
  53.                 CloseDir dh
  54.         End Method
  56.         Method FindFiles3(dir$)
  57.                 Local dh%=ReadDir(dir)
  58.                 If Not dh RuntimeError "failed to read current directory l3"
  60.                 Repeat
  61.                         Local temp$=NextFile(dh)
  62.                         If temp="" Then Exit ' done
  63.                         If temp="." Or temp=".." Continue ' skip
  64.                         Local cfile$=dir+"/"+temp ' current file
  65.                         If FileType(cfile)=1 ' file, html
  66.                                 If ExtractExt(cfile)="html" Then OpenHtml(cfile)
  67.                         EndIf
  68.                 Forever
  70.                 CloseDir dh
  71.         End Method
  73.         Method OpenHtml(path$)
  75.                 Local html$,file:TStream=OpenFile(path)
  76.                 If Not file RuntimeError "could not open file"
  78.                 While Not Eof(file)
  79.                         html=ReadString(file,FileSize(path))
  80.                         Local html2$,link$,lpart$
  81.                         Local fr%=html.Find("Function reference",0)
  82.                         Local fts%=fr,fbs%,fen%,fte%,fbe%
  84.                         If fr>0 ' file has functions
  85.                         html2=html
  86.                         Print "Adding Links: "+path[mdir.length+1..path.Find("index.html",mdir.length)-1]
  88.                                 While fts>-1 ' while functions in file
  89.                                         fts=html.Find("colspan=2>Function ",fts+1)
  90.                                         If fts>0
  91.                                                 fts:+19 ' to function name
  92.                                                 fbs=html.Find("(",fts) ' bracket start
  93.                                                 fte=html.Find("</td>",fts) ' table end
  94.                                                 fen=html[fts..fbs].Find(":",0) ' type (end of func name)
  95.                                                 If fen>0 Then fbs=fts+fen
  96.                                                 fen=html[fts..fbs].Find("[",0) ' array
  97.                                                 If fen>0 Then fbs=fts+fen
  98.                                                 fen=html[fts..fbs].Find("$",0) ' string
  99.                                                 If fen>0 Then fbs=fts+fen
  100.                                                 fen=html[fts..fbs].Find("#",0) ' float
  101.                                                 If fen>0 Then fbs=fts+fen
  102.                                                 fen=html[fts..fbs].Find("!",0) ' double
  103.                                                 If fen>0 Then fbs=fts+fen
  104.                                                 fen=html[fts..fbs].Find("_",0)
  106.                                                 If fen=-1 ' not a lua_func
  107.                                                         fen=html[fts..fbs].Find(" ",0) ' trim spaces
  108.                                                         If fen>0 Then fbs=fts+fen
  109.                                                         Local func$=html[fts..fbs] ' get func name
  110.                                                         fbe=html[fts..fte].Find("NoDebug",0) ' bracket end or nodebug
  111.                                                         If fbe=-1 Then fbe=html[fts..fte].FindLast(")",0) Else fbe:+6
  112.                                                         fbe:+fts+1
  113.                                                         link=html[fbe..fte] ' leave existing links alone
  114.                                                         lpart=" [<a href="+Chr(34)+""
  115.                                                         If fte-fbe=0
  116.                                                                 link=lpart+func+"&ref=goto"+Chr(34)+">Online doc</a>]" ' if no link add one
  117.                                                         EndIf
  118.                                                         html2=html[..fbe]+link+html[fte..]
  119.                                                 EndIf
  120.                                         EndIf
  121.                                         html=html2 ' update html
  122.                                 Wend
  124.                         EndIf
  125.                 Wend
  127.                 SeekStream file,0 ' overwrite file
  128.                 WriteString file,html
  129.                 CloseStream file
  131.         End Method
  133. End Type

Comments :

degac(Posted 1+ years ago)

 Well, not to all commands I think (look for AllocUserEventID for example!)It seems that online doc are not up to date with the one in the source code.

degac(Posted 1+ years ago)

 As you seem interested in working on documentation (I just see some other posts) an idea could be to do the inverse.*Look at the online documentation for each command*Download the page*Check if there are examples in the post (it should be the CODE/CODEBOX tag)*Save the content of the tags on the computer...I know this could be useless (if I have the link in my doc, just click on it to have the on line version and see other examples).But you could not be on internet... and examples - usually - needs when you cant' access internet!ps: idea2. You could change DocMods to create documentation+your link every time the user rebuild documentation. In the SRC folder there is the source code !EDIT: now the program/source is called MakeDocs (or something!)

markcw(Posted 1+ years ago)

 I did actually email Brl support about the missing functions and they said they would update these soon:In brl.Polledinput:MouseXSpeed, MouseYSpeed, MouseZSpeed.Also in brl.Event:EmitEvent, CreateEvent, AllocUserEventId.In brl.System:DesktopWidth, DesktopHeight, DesktopDepth, DesktopHertz.In brl.Max2d:SetVirtualResolution, VirtualResolutionWidth, VirtualResolutionHeight, VirtualMouseX, VirtualMouseY, VirtualMouseXSpeed, VirtualMouseYSpeed, MoveVirtualMouse.All of these were fairly recent additions in versions.txt but there may be some more.

degac(Posted 1+ years ago)

 I m happy to know this!

markcw(Posted 1+ years ago)

 I just found quite a few more missing entries and have emailed Brl support about it again. Here is a copy of the list:In Brl.D3D9Max2D:D3D9Max2DDriverIn Maxgui.ProxyGadgets:CreateHyperlink, CreateSplitter, SplitterPanel, SetSplitterPosition, SplitterPosition, SetSplitterOrientation, SplitterOrientation, SetSplitterBehavior, SplitterBehavior, CreateScrollPanel, ScrollPanelClient, FitScrollPanelClient, ScrollScrollPanel, ScrollPanelX, ScrollPanelYIn Maxgui.Localization:CreateLanguage, LoadLanguage, SaveLanguage, SetLanguageName, LanguageName, DefineLanguageToken, LanguageTokenDefinition, RemoveLanguageToken, ClearLanguageTokens, LocalizeString, SetLocalizationMode, LocalizationMode, SetLocalizationLanguage, LocalizationLanguageIn Brl.Threads:CreateThread, MainThread, CurrentThread, DetachThread, WaitThread, ThreadRunning, CreateThreadData, SetThreadDataValue, GetThreadDataValue, CreateMutex, CloseMutex, LockMutex, TryLockMutex, UnlockMutex, CreateSemaphore, CloseSemaphore, WaitSemaphore, PostSemaphore, CreateCondVar, CloseCondVar, WaitCondVar, SignalCondVar, BroadcastCondVar, CompareAndSwap, AtomicAdd, AtomicSwap

markcw(Posted 1+ years ago)

 In reply to your suggestions, I am intending to do something like that. Just to grab the code examples and build it into the offline docs and create files in the right place. Also, I hadn't thought of getting docmods/makedocs to run my code. I haven't really thought about editing makedocs yet. I'm just working on things I want to see, mainly I want to write a code highlighter. I "tweaked" makedocs before so I'll revisit that and see about getting a patch for it so all these things can happen on a "Rebuild docs".


SimplePortal 2.3.6 © 2008-2014, SimplePortal