Skip to content

Commit

Permalink
Update docs. Add link to online documentation [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Jul 3, 2016
1 parent 2267402 commit b63bf89
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ D library for working with *.desktop* files. Desktop entries in Freedesktop worl

[![Build Status](https://travis-ci.org/MyLittleRobo/desktopfile.svg?branch=master)](https://travis-ci.org/MyLittleRobo/desktopfile) [![Coverage Status](https://coveralls.io/repos/MyLittleRobo/desktopfile/badge.svg?branch=master&service=github)](https://coveralls.io/github/MyLittleRobo/desktopfile?branch=master)

[Online documentation](https://mylittlerobo.github.io/d-freedesktop/docs/desktopfile.html)

Most desktop environments on GNU/Linux and BSD flavors follow [Desktop Entry Specification](https://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/) today.
The goal of **desktopfile** library is to provide implementation of this specification in D programming language.
Please feel free to propose enchancements or report any related bugs to *Issues* page.
Expand Down
25 changes: 14 additions & 11 deletions source/desktopfile/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private @trusted void validateDesktopKeyImpl(string groupName, string key, strin
}

/**
* Subclass of IniLikeGroup for easy access to desktop action.
* Subclass of $(D inilike.file.IniLikeGroup) for easy access to desktop action.
*/
final class DesktopAction : IniLikeGroup
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public:
}

/**
* Subclass of IniLikeGroup for easy accessing of Desktop Entry properties.
* Subclass of $(D inilike.file.IniLikeGroup) for easy accessing of Desktop Entry properties.
*/
final class DesktopEntry : IniLikeGroup
{
Expand Down Expand Up @@ -147,7 +147,7 @@ final class DesktopEntry : IniLikeGroup

/**
* Sets "Type" field to type
* Note: Setting the Type.Unknown removes type field.
* Note: Setting the $(D Type.Unknown) removes type field.
*/
@safe Type type(Type t) {
final switch(t) {
Expand Down Expand Up @@ -293,7 +293,9 @@ final class DesktopEntry : IniLikeGroup
}

/**
* Value used to determine if the program is actually installed. If the path is not an absolute path, the file should be looked up in the $(B PATH) environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example).
* Value used to determine if the program is actually installed.
*
* If the path is not an absolute path, the file should be looked up in the $(B PATH) environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example).
* Returns: The value associated with "TryExec" key.
* See_Also: $(D execValue)
*/
Expand Down Expand Up @@ -575,7 +577,7 @@ final class DesktopEntry : IniLikeGroup
/**
* Check if desktop file should be shown in menu of specific desktop environment.
* Params:
* desktopEnvironment = Name of desktop environment, usually detected by XDG_CURRENT_DESKTOP variable.
* desktopEnvironment = Name of desktop environment, usually detected by $(B XDG_CURRENT_DESKTOP) variable.
* See_Also: $(LINK2 https://specifications.freedesktop.org/menu-spec/latest/apb.html, Registered OnlyShowIn Environments), $(D notShowIn), $(D onlyShowIn)
*/
@trusted bool showIn(string desktopEnvironment)
Expand Down Expand Up @@ -650,7 +652,7 @@ public:
///Options to manage desktop file reading
static struct DesktopReadOptions
{
///Base $(B ReadOptions) of $(B IniLikeFile).
///Base $(D inilike.file.IniLikeFile.ReadOptions).
IniLikeFile.ReadOptions baseOptions;

alias baseOptions this;
Expand Down Expand Up @@ -822,7 +824,7 @@ public:
* Reads desktop file from file.
* Throws:
* $(B ErrnoException) if file could not be opened.
* $(B IniLikeReadException) if error occured while reading the file or "Desktop Entry" group is missing.
* $(D inilike.file.IniLikeReadException) if error occured while reading the file or "Desktop Entry" group is missing.
*/
@trusted this(string fileName, DesktopReadOptions options = DesktopReadOptions.init) {
this(iniLikeFileReader(fileName), options, fileName);
Expand All @@ -831,7 +833,7 @@ public:
/**
* Reads desktop file from IniLikeReader, e.g. acquired from iniLikeFileReader or iniLikeStringReader.
* Throws:
* $(B IniLikeReadException) if error occured while parsing or "Desktop Entry" group is missing.
* $(D inilike.file.IniLikeReadException) if error occured while parsing or "Desktop Entry" group is missing.
*/
this(IniLikeReader)(IniLikeReader reader, DesktopReadOptions options = DesktopReadOptions.init, string fileName = null)
{
Expand All @@ -844,7 +846,7 @@ public:
/**
* Reads desktop file from IniLikeReader, e.g. acquired from iniLikeFileReader or iniLikeStringReader.
* Throws:
* $(B IniLikeReadException) if error occured while parsing or "Desktop Entry" group is missing.
* $(D inilike.file.IniLikeReadException) if error occured while parsing or "Desktop Entry" group is missing.
*/
this(IniLikeReader)(IniLikeReader reader, string fileName, DesktopReadOptions options = DesktopReadOptions.init)
{
Expand Down Expand Up @@ -1146,6 +1148,7 @@ Icon[ru]=folder_ru`;

/**
* Starts the application associated with this .desktop file using urls as command line params.
*
* If the program should be run in terminal it tries to find system defined terminal emulator to run in.
* Params:
* urls = urls application will start with.
Expand Down Expand Up @@ -1198,7 +1201,7 @@ Icon[ru]=folder_ru`;
}
}

///ditto, but uses the only url.
///Starts the application associated with this .desktop file using url as command line params.
@trusted Pid startApplication(string url, string locale = null, lazy const(string)[] terminalCommand = getTerminalCommand) const {
return startApplication([url], locale, terminalCommand);
}
Expand Down Expand Up @@ -1229,7 +1232,7 @@ Icon[ru]=folder_ru`;
* Starts application or open link depending on desktop entry type.
* Throws:
* ProcessException on failure to start the process.
* Exception if type is Unknown or Directory.
* Exception if type is $(D DesktopEntry.Type.Unknown) or $(D DesktopEntry.Type.Directory).
* See_Also: $(D startApplication), $(D startLink)
*/
@trusted void start() const
Expand Down
14 changes: 9 additions & 5 deletions source/desktopfile/utils.d
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,14 @@ unittest
}

/**
* Apply unquoting to Exec value making it into an array of escaped arguments. It automatically performs quote-related unescaping. Read more: [specification](http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html).
* Apply unquoting to Exec value making it into an array of escaped arguments. It automatically performs quote-related unescaping.
* Params:
* value = value of Exec key. Must be unescaped by unescapeValue before passing.
* Throws:
* $(D DesktopExecException) if string can't be unquoted (e.g. no pair quote).
* Note:
* Although Desktop Entry Specification says that arguments must be quoted by double quote, for compatibility reasons this implementation also recognizes single quotes.
* See_Also: $(LINK2 http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html, specification)
*/
@trusted auto unquoteExec(string value) pure
{
Expand Down Expand Up @@ -333,7 +334,7 @@ private @trusted string urlToFilePath(string url) nothrow pure
}

/**
* Expand Exec arguments (usually returned by unquoteExec) replacing field codes with given values, making the array suitable for passing to spawnProcess. Deprecated field codes are ignored.
* Expand Exec arguments (usually returned by $(D unquoteExec)) replacing field codes with given values, making the array suitable for passing to spawnProcess. Deprecated field codes are ignored.
* Note:
* Returned array may be empty and should be checked before passing to spawnProcess.
* Params:
Expand Down Expand Up @@ -691,6 +692,7 @@ unittest

/**
* Detect command which will run program in terminal emulator.
*
* On Freedesktop it looks for x-terminal-emulator first. If found ["/path/to/x-terminal-emulator", "-e"] is returned.
* Otherwise it looks for xdg-terminal. If found ["/path/to/xdg-terminal"] is returned.
* Otherwise it tries to detect your desktop environment and find default terminal emulator for it.
Expand Down Expand Up @@ -1187,9 +1189,11 @@ static if (isFreedesktop)
}

/**
* Check if .desktop file is trusted. This is not actually part of Desktop File Specification but many file managers has this concept.
* The trusted .desktop file is a file the current user has executable access to or the owner of which is root.
* This function should be applicable only to desktop files of Application type.
* Check if .desktop file is trusted.
*
* This is not actually part of Desktop File Specification but many desktop envrionments have this concept.
* The trusted .desktop file is a file the current user has executable access on or the owner of which is root.
* This function should be applicable only to desktop files of $(D DesktopEntry.Type.Application) type.
* Note: Always returns true on non-posix systems.
*/
@trusted bool isTrusted(string appFileName) nothrow
Expand Down

0 comments on commit b63bf89

Please sign in to comment.